Class: Workarea::Listrak::DataApi::Products
- Inherits:
-
Object
- Object
- Workarea::Listrak::DataApi::Products
- Defined in:
- app/services/workarea/listrak/data_api/products.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#import(products) ⇒ String
Starts a new import using the supplied product collection.
-
#initialize(client) ⇒ Products
constructor
A new instance of Products.
Constructor Details
#initialize(client) ⇒ Products
Returns a new instance of Products.
6 7 8 |
# File 'app/services/workarea/listrak/data_api/products.rb', line 6 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'app/services/workarea/listrak/data_api/products.rb', line 4 def client @client end |
Instance Method Details
#import(products) ⇒ String
Starts a new import using the supplied product collection.
16 17 18 19 20 21 22 23 |
# File 'app/services/workarea/listrak/data_api/products.rb', line 16 def import(products) request = Net::HTTP::Post.new("/data/v1/Product").tap do |post| post.body = products.to_json end response = client.request request body = JSON.parse(response.body) body["resourceId"] end |