class Io::Flow::V0::Clients::Attributes
Public Class Methods
new(client)
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 829 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end
Public Instance Methods
delete_by_key(organization, key)
click to toggle source
Delete an attribute with the specified key.
# File lib/flow_commerce/flow_api_v0_client.rb, line 898 def delete_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/attributes/#{CGI.escape(key)}").delete nil end
get(organization, incoming={})
click to toggle source
Search attributes. Always paginated.
# File lib/flow_commerce/flow_api_v0_client.rb, line 834 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) }), :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, Array).map { |v| HttpClient::Preconditions.assert_class('key', v, String) }), :intent => (x = opts.delete(:intent); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::AttributeIntent) ? x : ::Io::Flow::V0::Models::AttributeIntent.apply(x)).value), :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? ? "position" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/attributes").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Attribute.new(x) } end
get_by_key(organization, key)
click to toggle source
Returns
information about a specific attribute.
# File lib/flow_commerce/flow_api_v0_client.rb, line 881 def get_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/attributes/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::Attribute.new(r) end
get_versions(organization, incoming={})
click to toggle source
Provides visibility into recent changes of each object, including deletion
# File lib/flow_commerce/flow_api_v0_client.rb, line 866 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) }), :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, Array).map { |v| HttpClient::Preconditions.assert_class('key', 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)}/attributes/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::AttributeVersion.new(x) } end
post(organization, attribute_form)
click to toggle source
Add attribute
# File lib/flow_commerce/flow_api_v0_client.rb, line 850 def post(organization, attribute_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = attribute_form; x.is_a?(::Io::Flow::V0::Models::AttributeForm) ? x : ::Io::Flow::V0::Models::AttributeForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/attributes").with_json(attribute_form.to_json).post ::Io::Flow::V0::Models::Attribute.new(r) end
put(organization, attribute_forms)
click to toggle source
Create or update a batch of attributes
# File lib/flow_commerce/flow_api_v0_client.rb, line 858 def put(organization, attribute_forms) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('attribute_forms', attribute_forms, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AttributeForm) ? x : ::Io::Flow::V0::Models::AttributeForm.new(x)) } r = @client.request("/#{CGI.escape(organization)}/attributes").with_json(attribute_forms.map { |o| o.to_hash }.to_json).put r.map { |x| ::Io::Flow::V0::Models::Attribute.new(x) } end
put_by_key(organization, key, attribute_form)
click to toggle source
Create or update an attribute with the specified key.
# File lib/flow_commerce/flow_api_v0_client.rb, line 889 def put_by_key(organization, key, attribute_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = attribute_form; x.is_a?(::Io::Flow::V0::Models::AttributeForm) ? x : ::Io::Flow::V0::Models::AttributeForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/attributes/#{CGI.escape(key)}").with_json(attribute_form.to_json).put ::Io::Flow::V0::Models::Attribute.new(r) end