Class: Io::Flow::V0::Clients::SyncStreams

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ SyncStreams

Returns a new instance of SyncStreams.



8828
8829
8830
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8828

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#delete_by_key(organization, key) ⇒ Object



8869
8870
8871
8872
8873
8874
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8869

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



8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8832

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



8854
8855
8856
8857
8858
8859
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8854

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



8847
8848
8849
8850
8851
8852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8847

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



8861
8862
8863
8864
8865
8866
8867
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8861

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