Class: Workarea::Listrak::DataApi::Customers

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Customers

Returns a new instance of Customers.



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

def client
  @client
end

Instance Method Details

#import(customers) ⇒ String

Starts a new import using the supplied customer collection.

Parameters:

Returns:

  • (String)

    resource_id



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

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