-1

Here is my code.

(use '[leiningen.exec :only (deps)])
(deps '[[org.clojure/clojure "1.4.0"]
       [org.clojure/data.zip "0.1.1"]])
(deps '[[clj-http "0.5.8"]
       [org.clojars.rorygibson/clj-amazon "0.3.0-SNAPSHOT"]]
  )

(def ACCESS-KEY "my access key" )
(def SECRET-KEY "my secret key" )
(def ASSOCIATE-ID "my id")

(def ENDPOINT "webservices.amazon.co.uk") 

(def signer (signed-request-helper ACCESS-KEY SECRETE-KEY ASSOCIATE-ID))

(def gibson-opus-search (item-search :signer signer :search-index "Books", :keywords "Neuromancer", :associate-tag ASSOCIATE-ID, :condition "New"))

(def lookup-specific-item (item-lookup :signer signer :associate-tag ASSOCIATE-ID :item-id "B0069KPSPC" :response-group   "ItemAttributes,OfferSummary"))

I'm trying to use Amazon's product api on Clojure. When I try lein exec on the command prompt, I get unable to resolve symbol: signed-request helper in this context. How can I fix this problem?

Alex Miller
  • 69,183
  • 25
  • 122
  • 167
codingXeno
  • 65
  • 2
  • Are you using lein deps instead of a defproject for a particular reason? That error suggests that your dependencies are not being successfully included. – jmargolisvt Nov 05 '16 at 14:25

2 Answers2

2

The deps call sets up the classpath so your dependencies are available. You'll need to require a namespace to load it and then refer (within the require) to make those external symbols available to your code. Or alternately, you can use the external namespace to both load and refer (although this is generally discouraged stylistically these days).

In this example:

(require '[clj-amazon.core :refer [signed-request-helper]]
         '[clj-amazon.product-advertising :refer [item-search item-lookup])

Or:

(use 'clj-amazon.core
     'clj-amazon.product-advertising)

Generally the require version is preferred because it is then visually traceable where functions used in your code came from.

Alex Miller
  • 69,183
  • 25
  • 122
  • 167
1

You never define signed-request-helper in that context, so of course it unresolvable. You need to either provide a definition or, if it's included in one of the dependencies, you need to use or require the appropriate namespace.

Nathan Davis
  • 5,636
  • 27
  • 39