Class: CustomerioAPI::CustomerResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/customerio_api/resources/customer_resource.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#get_request, #handle_response, #initialize, #post_request, #put_request

Constructor Details

This class inherits a constructor from CustomerioAPI::Resource

Instance Method Details

#search(attributes:, start: nil, limit: nil) ⇒ Object

client.customer.search(attributes: attributes)



15
16
17
18
# File 'lib/customerio_api/resources/customer_resource.rb', line 15

def search(attributes:, start: nil, limit: nil)
  response_body = post_request("customers?start=#{start}&limit=#{limit}", body: attributes).body
  Customer.new(response_body)
end

#where(email:) ⇒ Object

client.customer.where(email: “[email protected]”) Response:

#<CustomerioAPI::Customer email=“[email protected]”, id=“test1”, cio_id=“d7a90a000102”>


9
10
11
12
# File 'lib/customerio_api/resources/customer_resource.rb', line 9

def where(email:)
  response_body = get_request('customers', params: { email: email }).body
  response_body['results'].map { |customers| Customer.new(customers) }
end