Class: SearchSpring::Client
- Inherits:
-
Object
- Object
- SearchSpring::Client
- Defined in:
- lib/search_spring/client.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
-
#site_id ⇒ Object
readonly
Returns the value of attribute site_id.
Instance Method Summary collapse
- #delete(feed_id:, product_ids: []) ⇒ Object
-
#initialize(site_id, secret_key, req_options = {}) ⇒ Client
constructor
A new instance of Client.
- #update(feed_id:, products: []) ⇒ Object
- #upsert(feed_id:, products: []) ⇒ Object
Constructor Details
#initialize(site_id, secret_key, req_options = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/search_spring/client.rb', line 8 def initialize(site_id, secret_key, = {}) @site_id = site_id @secret_key = secret_key raise Errors::AuthenticationError, 'No Site ID provided.' unless @site_id unless @secret_key raise Errors::AuthenticationError, 'No Secret Key provided.' end @conn = connection() end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
6 7 8 |
# File 'lib/search_spring/client.rb', line 6 def conn @conn end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
6 7 8 |
# File 'lib/search_spring/client.rb', line 6 def secret_key @secret_key end |
#site_id ⇒ Object (readonly)
Returns the value of attribute site_id.
6 7 8 |
# File 'lib/search_spring/client.rb', line 6 def site_id @site_id end |
Instance Method Details
#delete(feed_id:, product_ids: []) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/search_spring/client.rb', line 41 def delete(feed_id:, product_ids: []) conn.post do |req| req.url 'api/index/delete.json' req.headers['Content-Type'] = 'application/json' req.body = MultiJson.dump( feedId: feed_id, records: product_ids ) end end |
#update(feed_id:, products: []) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/search_spring/client.rb', line 30 def update(feed_id:, products: []) conn.post do |req| req.url 'api/index/update.json' req.headers['Content-Type'] = 'application/json' req.body = MultiJson.dump( feedId: feed_id, records: products ) end end |
#upsert(feed_id:, products: []) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/search_spring/client.rb', line 19 def upsert(feed_id:, products: []) conn.post do |req| req.url 'api/index/upsert.json' req.headers['Content-Type'] = 'application/json' req.body = MultiJson.dump( feedId: feed_id, records: products ) end end |