Class: Workarea::Listrak::DataApi::Products

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/listrak/data_api/products.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (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.

Parameters:

Returns:

  • (String)

    resource id



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