Class: Io::Flow::V0::Clients::SyncRecords
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::SyncRecords
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(organization, id) ⇒ Object
-
#delete_streams_and_systems_and_values_by_stream_key_and_system_and_value(organization, stream_key, system, value) ⇒ Object
Delete a value for a system for this stream.
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
-
#initialize(client) ⇒ SyncRecords
constructor
A new instance of SyncRecords.
- #post(organization, sync_record_form) ⇒ Object
- #put_by_id(organization, id, sync_record_form) ⇒ Object
-
#put_streams_and_systems_and_values_by_stream_key_and_system_and_value(organization, stream_key, system, value) ⇒ Object
Idempotent method to upsert a value for a system for this stream.
Constructor Details
#initialize(client) ⇒ SyncRecords
Returns a new instance of SyncRecords.
7428 7429 7430 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7428 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
7490 7491 7492 7493 7494 7495 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7490 def delete_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/sync/records/#{CGI.escape(id)}").delete nil end |
#delete_streams_and_systems_and_values_by_stream_key_and_system_and_value(organization, stream_key, system, value) ⇒ Object
Delete a value for a system for this stream.
7466 7467 7468 7469 7470 7471 7472 7473 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7466 def delete_streams_and_systems_and_values_by_stream_key_and_system_and_value(organization, stream_key, system, value) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('stream_key', stream_key, String) HttpClient::Preconditions.assert_class('system', system, String) HttpClient::Preconditions.assert_class('value', value, String) r = @client.request("/#{CGI.escape(organization)}/sync/records/streams/#{CGI.escape(stream_key)}/systems/#{CGI.escape(system)}/values/#{CGI.escape(value)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7432 def get(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, 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) }), :stream_key => (x = opts.delete(:stream_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('stream_key', x, String)), :system => (x = opts.delete(:system); x.nil? ? nil : HttpClient::Preconditions.assert_class('system', x, String)), :value => (x = opts.delete(:value); x.nil? ? nil : HttpClient::Preconditions.assert_class('value', x, 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)}/sync/records").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::SyncRecord.new(x) } end |
#get_by_id(organization, id) ⇒ Object
7475 7476 7477 7478 7479 7480 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7475 def get_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/sync/records/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::SyncRecord.new(r) end |
#post(organization, sync_record_form) ⇒ Object
7448 7449 7450 7451 7452 7453 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7448 def post(organization, sync_record_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = sync_record_form; x.is_a?(::Io::Flow::V0::Models::SyncRecordForm) ? x : ::Io::Flow::V0::Models::SyncRecordForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/sync/records").with_json(sync_record_form.to_json).post ::Io::Flow::V0::Models::SyncRecord.new(r) end |
#put_by_id(organization, id, sync_record_form) ⇒ Object
7482 7483 7484 7485 7486 7487 7488 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7482 def put_by_id(organization, id, sync_record_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) (x = sync_record_form; x.is_a?(::Io::Flow::V0::Models::SyncRecordForm) ? x : ::Io::Flow::V0::Models::SyncRecordForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/sync/records/#{CGI.escape(id)}").with_json(sync_record_form.to_json).put ::Io::Flow::V0::Models::SyncRecord.new(r) end |
#put_streams_and_systems_and_values_by_stream_key_and_system_and_value(organization, stream_key, system, value) ⇒ Object
Idempotent method to upsert a value for a system for this stream.
7456 7457 7458 7459 7460 7461 7462 7463 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7456 def put_streams_and_systems_and_values_by_stream_key_and_system_and_value(organization, stream_key, system, value) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('stream_key', stream_key, String) HttpClient::Preconditions.assert_class('system', system, String) HttpClient::Preconditions.assert_class('value', value, String) r = @client.request("/#{CGI.escape(organization)}/sync/records/streams/#{CGI.escape(stream_key)}/systems/#{CGI.escape(system)}/values/#{CGI.escape(value)}").put ::Io::Flow::V0::Models::SyncRecord.new(r) end |