Class: Io::Flow::V0::Clients::Feeds

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Feeds

Returns a new instance of Feeds.



4627
4628
4629
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4627

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

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



4659
4660
4661
4662
4663
4664
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4659

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)}/feeds/#{CGI.escape(id)}").delete
  nil
end

#get(organization, incoming = {}) ⇒ Object



4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4631

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) }),
    :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)}/feeds").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::Feed.from_json(x) }
end

#post_catalog(organization, catalog_feed_form_post) ⇒ Object



4644
4645
4646
4647
4648
4649
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4644

def post_catalog(organization, catalog_feed_form_post)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = catalog_feed_form_post; x.is_a?(::Io::Flow::V0::Models::CatalogFeedFormPost) ? x : ::Io::Flow::V0::Models::CatalogFeedFormPost.new(x))
  r = @client.request("/#{CGI.escape(organization)}/feeds/catalog").with_json(catalog_feed_form_post.to_json).post
  ::Io::Flow::V0::Models::CatalogFeed.new(r)
end

#put_catalog_by_id(organization, id, catalog_feed_form_put) ⇒ Object



4651
4652
4653
4654
4655
4656
4657
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4651

def put_catalog_by_id(organization, id, catalog_feed_form_put)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = catalog_feed_form_put; x.is_a?(::Io::Flow::V0::Models::CatalogFeedFormPut) ? x : ::Io::Flow::V0::Models::CatalogFeedFormPut.new(x))
  r = @client.request("/#{CGI.escape(organization)}/feeds/catalog/#{CGI.escape(id)}").with_json(catalog_feed_form_put.to_json).put
  ::Io::Flow::V0::Models::CatalogFeed.new(r)
end