Class: Io::Flow::V0::Clients::Feeds
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Feeds
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(organization, id) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ Feeds
constructor
A new instance of Feeds.
- #post_catalog(organization, catalog_feed_form_post) ⇒ Object
- #put_catalog_by_id(organization, id, catalog_feed_form_put) ⇒ Object
Constructor Details
#initialize(client) ⇒ Feeds
Returns a new instance of Feeds.
3887 3888 3889 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3887 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
3904 3905 3906 3907 3908 3909 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3904 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
3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3891 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
3911 3912 3913 3914 3915 3916 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3911 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
3918 3919 3920 3921 3922 3923 3924 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3918 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 |