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.



4178
4179
4180
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4178

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

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



4195
4196
4197
4198
4199
4200
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4195

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



4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4182

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



4202
4203
4204
4205
4206
4207
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4202

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



4209
4210
4211
4212
4213
4214
4215
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4209

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