Class: Io::Flow::V0::Clients::SyncStreams
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::SyncStreams
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_key(organization, key) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_key(organization, key) ⇒ Object
-
#initialize(client) ⇒ SyncStreams
constructor
A new instance of SyncStreams.
- #post(organization, sync_stream_form) ⇒ Object
- #put_by_key(organization, key, sync_stream_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ SyncStreams
Returns a new instance of SyncStreams.
8391 8392 8393 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8391 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
8432 8433 8434 8435 8436 8437 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8432 def delete_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/sync/streams/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8395 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) }), :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String)), :type => (x = opts.delete(:type); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::SyncStreamType) ? x : ::Io::Flow::V0::Models::SyncStreamType.apply(x)).value), :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/streams").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::SyncStream.new(x) } end |
#get_by_key(organization, key) ⇒ Object
8417 8418 8419 8420 8421 8422 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8417 def get_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/sync/streams/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::SyncStream.new(r) end |
#post(organization, sync_stream_form) ⇒ Object
8410 8411 8412 8413 8414 8415 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8410 def post(organization, sync_stream_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = sync_stream_form; x.is_a?(::Io::Flow::V0::Models::SyncStreamForm) ? x : ::Io::Flow::V0::Models::SyncStreamForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/sync/streams").with_json(sync_stream_form.to_json).post ::Io::Flow::V0::Models::SyncStream.new(r) end |
#put_by_key(organization, key, sync_stream_form) ⇒ Object
8424 8425 8426 8427 8428 8429 8430 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8424 def put_by_key(organization, key, sync_stream_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = sync_stream_form; x.is_a?(::Io::Flow::V0::Models::SyncStreamForm) ? x : ::Io::Flow::V0::Models::SyncStreamForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/sync/streams/#{CGI.escape(key)}").with_json(sync_stream_form.to_json).put ::Io::Flow::V0::Models::SyncStream.new(r) end |