Class: Io::Flow::V0::Clients::Catalogs
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Catalogs
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_catalog_and_restrictions_by_number(organization, number) ⇒ Object
Delete the global restriction for this catalog item number.
-
#get_catalog(organization) ⇒ Object
Returns information about a specific catalog.
-
#get_catalog_and_restrictions(organization, incoming = {}) ⇒ Object
Search global restrictions.
-
#get_catalog_and_restrictions_by_number(organization, number) ⇒ Object
Returns a specific globally restricted item.
-
#get_catalog_and_statistics(organization) ⇒ Object
Get statistics for this organization's catalog.
-
#initialize(client) ⇒ Catalogs
constructor
A new instance of Catalogs.
-
#put_catalog_and_restrictions_by_number(organization, number) ⇒ Object
Upsert a global restriction.
Constructor Details
#initialize(client) ⇒ Catalogs
Returns a new instance of Catalogs.
735 736 737 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 735 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_catalog_and_restrictions_by_number(organization, number) ⇒ Object
Delete the global restriction for this catalog item number
778 779 780 781 782 783 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 778 def delete_catalog_and_restrictions_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/catalog/restrictions/#{CGI.escape(number)}").delete nil end |
#get_catalog(organization) ⇒ Object
Returns information about a specific catalog.
740 741 742 743 744 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 740 def get_catalog(organization) HttpClient::Preconditions.assert_class('organization', organization, String) r = @client.request("/#{CGI.escape(organization)}/catalog").get ::Io::Flow::V0::Models::Catalog.new(r) end |
#get_catalog_and_restrictions(organization, incoming = {}) ⇒ Object
Search global restrictions. Always paginated.
747 748 749 750 751 752 753 754 755 756 757 758 759 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 747 def get_catalog_and_restrictions(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) }), :number => (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, Array).map { |v| HttpClient::Preconditions.assert_class('number', 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? ? "name" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/catalog/restrictions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Item.new(x) } end |
#get_catalog_and_restrictions_by_number(organization, number) ⇒ Object
Returns a specific globally restricted item.
762 763 764 765 766 767 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 762 def get_catalog_and_restrictions_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/catalog/restrictions/#{CGI.escape(number)}").get ::Io::Flow::V0::Models::Item.new(r) end |
#get_catalog_and_statistics(organization) ⇒ Object
Get statistics for this organization's catalog.
786 787 788 789 790 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 786 def get_catalog_and_statistics(organization) HttpClient::Preconditions.assert_class('organization', organization, String) r = @client.request("/#{CGI.escape(organization)}/catalog/statistics").get ::Io::Flow::V0::Models::CatalogStatistics.new(r) end |
#put_catalog_and_restrictions_by_number(organization, number) ⇒ Object
Upsert a global restriction
770 771 772 773 774 775 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 770 def put_catalog_and_restrictions_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/catalog/restrictions/#{CGI.escape(number)}").put ::Io::Flow::V0::Models::Item.new(r) end |