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.
8701 8702 8703 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8701 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
8763 8764 8765 8766 8767 8768 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8763 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.
8739 8740 8741 8742 8743 8744 8745 8746 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8739 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
8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8705 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
8748 8749 8750 8751 8752 8753 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8748 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
8721 8722 8723 8724 8725 8726 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8721 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
8755 8756 8757 8758 8759 8760 8761 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8755 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.
8729 8730 8731 8732 8733 8734 8735 8736 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8729 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 |