Class: Io::Flow::V0::Clients::Subcatalogs
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Subcatalogs
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_id(organization, id) ⇒ Object
Delete the subcatalog with this id.
-
#get(organization, incoming = {}) ⇒ Object
Search subcatalogs.
-
#get_by_id(organization, id) ⇒ Object
Returns information about a specific subcatalog.
-
#get_settings_by_id(organization, id) ⇒ Object
Returns information about a specific subcatalog’s settings.
-
#get_statistics_by_subcatalog_id(organization, subcatalog_id) ⇒ Object
Get statistics for the specified subcatalog.
-
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion.
-
#initialize(client) ⇒ Subcatalogs
constructor
A new instance of Subcatalogs.
-
#post(organization, subcatalog_form) ⇒ Object
Add subcatalog.
-
#put_by_id(organization, id, subcatalog_form) ⇒ Object
Update subcatalog with the specified id, creating if it does not exist.
-
#put_settings_by_id(organization, id, subcatalog_settings_form) ⇒ Object
Update subcatalog settings for the specified subcatalog.
Constructor Details
#initialize(client) ⇒ Subcatalogs
Returns a new instance of Subcatalogs.
2998 2999 3000 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2998 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
Delete the subcatalog with this id
3056 3057 3058 3059 3060 3061 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3056 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)}/catalog/subcatalogs/#{CGI.escape(id)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
Search subcatalogs. Always paginated.
3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3003 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)}/catalog/subcatalogs").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Subcatalog.new(x) } end |
#get_by_id(organization, id) ⇒ Object
Returns information about a specific subcatalog.
3039 3040 3041 3042 3043 3044 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3039 def get_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/catalog/subcatalogs/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Subcatalog.new(r) end |
#get_settings_by_id(organization, id) ⇒ Object
Returns information about a specific subcatalog’s settings.
3064 3065 3066 3067 3068 3069 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3064 def get_settings_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/catalog/subcatalogs/#{CGI.escape(id)}/settings").get ::Io::Flow::V0::Models::SubcatalogSettings.new(r) end |
#get_statistics_by_subcatalog_id(organization, subcatalog_id) ⇒ Object
Get statistics for the specified subcatalog
3081 3082 3083 3084 3085 3086 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3081 def get_statistics_by_subcatalog_id(organization, subcatalog_id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('subcatalog_id', subcatalog_id, String) r = @client.request("/#{CGI.escape(organization)}/catalog/subcatalogs/#{CGI.escape(subcatalog_id)}/statistics").get ::Io::Flow::V0::Models::SubcatalogStatistics.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3025 def get_versions(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? ? "journal_timestamp" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/catalog/subcatalogs/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::SubcatalogVersion.new(x) } end |
#post(organization, subcatalog_form) ⇒ Object
Add subcatalog
3017 3018 3019 3020 3021 3022 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3017 def post(organization, subcatalog_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = subcatalog_form; x.is_a?(::Io::Flow::V0::Models::SubcatalogForm) ? x : ::Io::Flow::V0::Models::SubcatalogForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/catalog/subcatalogs").with_json(subcatalog_form.to_json).post ::Io::Flow::V0::Models::Subcatalog.new(r) end |
#put_by_id(organization, id, subcatalog_form) ⇒ Object
Update subcatalog with the specified id, creating if it does not exist.
3047 3048 3049 3050 3051 3052 3053 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3047 def put_by_id(organization, id, subcatalog_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) (x = subcatalog_form; x.is_a?(::Io::Flow::V0::Models::SubcatalogForm) ? x : ::Io::Flow::V0::Models::SubcatalogForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/catalog/subcatalogs/#{CGI.escape(id)}").with_json(subcatalog_form.to_json).put ::Io::Flow::V0::Models::Subcatalog.new(r) end |
#put_settings_by_id(organization, id, subcatalog_settings_form) ⇒ Object
Update subcatalog settings for the specified subcatalog.
3072 3073 3074 3075 3076 3077 3078 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3072 def put_settings_by_id(organization, id, subcatalog_settings_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) (x = subcatalog_settings_form; x.is_a?(::Io::Flow::V0::Models::SubcatalogSettingsForm) ? x : ::Io::Flow::V0::Models::SubcatalogSettingsForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/catalog/subcatalogs/#{CGI.escape(id)}/settings").with_json(subcatalog_settings_form.to_json).put ::Io::Flow::V0::Models::SubcatalogSettings.new(r) end |