Class: Workarea::Listrak::DataApi::Orders

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Orders

Returns a new instance of Orders.



6
7
8
# File 'app/services/workarea/listrak/data_api/orders.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/orders.rb', line 4

def client
  @client
end

Instance Method Details

#import(orders) ⇒ String

Starts a new import using the supplied order collection.

Parameters:

Returns:

  • (String)

    resource id



16
17
18
19
20
21
22
23
# File 'app/services/workarea/listrak/data_api/orders.rb', line 16

def import(orders)
  request = Net::HTTP::Post.new("/data/v1/Order").tap do |post|
    post.body = orders.to_json
  end
  response = client.request request
  body = JSON.parse(response.body)
  body["resourceId"]
end