Class: Io::Flow::V0::Clients::CustomerAddressBookContacts
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::CustomerAddressBookContacts
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_id(organization, number, id) ⇒ Object
Delete the contact with this id.
-
#get(organization, number, incoming = {}) ⇒ Object
Search contacts.
-
#get_by_id(organization, number, id) ⇒ Object
Returns information about a specific contact.
-
#initialize(client) ⇒ CustomerAddressBookContacts
constructor
A new instance of CustomerAddressBookContacts.
-
#post(organization, number, customer_address_book_contact_form) ⇒ Object
Create a contact.
-
#put_by_id(organization, number, id, customer_address_book_contact_form) ⇒ Object
Update or create a contact with the specified id.
Constructor Details
#initialize(client) ⇒ CustomerAddressBookContacts
Returns a new instance of CustomerAddressBookContacts.
6448 6449 6450 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6448 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, number, id) ⇒ Object
Delete the contact with this id.
6498 6499 6500 6501 6502 6503 6504 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6498 def delete_by_id(organization, number, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/customers/#{CGI.escape(number)}/addresses/book/contacts/#{CGI.escape(id)}").delete nil end |
#get(organization, number, incoming = {}) ⇒ Object
Search contacts. Always paginated.
6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6453 def get(organization, number, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :email => (x = opts.delete(:email); x.nil? ? nil : HttpClient::Preconditions.assert_class('email', x, Array).map { |v| HttpClient::Preconditions.assert_class('email', v, String) }), :phone => (x = opts.delete(:phone); x.nil? ? nil : HttpClient::Preconditions.assert_class('phone', x, Array).map { |v| HttpClient::Preconditions.assert_class('phone', v, String) }), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/customers/#{CGI.escape(number)}/addresses/book/contacts").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::CustomerAddressBookContact.new(x) } end |
#get_by_id(organization, number, id) ⇒ Object
Returns information about a specific contact.
6479 6480 6481 6482 6483 6484 6485 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6479 def get_by_id(organization, number, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/customers/#{CGI.escape(number)}/addresses/book/contacts/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::CustomerAddressBookContact.new(r) end |
#post(organization, number, customer_address_book_contact_form) ⇒ Object
Create a contact.
6470 6471 6472 6473 6474 6475 6476 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6470 def post(organization, number, customer_address_book_contact_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) (x = customer_address_book_contact_form; x.is_a?(::Io::Flow::V0::Models::CustomerAddressBookContactForm) ? x : ::Io::Flow::V0::Models::CustomerAddressBookContactForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/customers/#{CGI.escape(number)}/addresses/book/contacts").with_json(customer_address_book_contact_form.to_json).post ::Io::Flow::V0::Models::CustomerAddressBookContact.new(r) end |
#put_by_id(organization, number, id, customer_address_book_contact_form) ⇒ Object
Update or create a contact with the specified id.
6488 6489 6490 6491 6492 6493 6494 6495 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6488 def put_by_id(organization, number, id, customer_address_book_contact_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) HttpClient::Preconditions.assert_class('id', id, String) (x = customer_address_book_contact_form; x.is_a?(::Io::Flow::V0::Models::CustomerAddressBookContactForm) ? x : ::Io::Flow::V0::Models::CustomerAddressBookContactForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/customers/#{CGI.escape(number)}/addresses/book/contacts/#{CGI.escape(id)}").with_json(customer_address_book_contact_form.to_json).put ::Io::Flow::V0::Models::CustomerAddressBookContact.new(r) end |