Class: Io::Flow::V0::Clients::ItemFunctions
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::ItemFunctions
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_key(organization, key) ⇒ Object
Delete the item function with this key.
-
#get(organization, incoming = {}) ⇒ Object
Search item functions.
-
#get_by_key(organization, key) ⇒ Object
Returns information about a specific item function.
-
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion.
-
#initialize(client) ⇒ ItemFunctions
constructor
A new instance of ItemFunctions.
-
#post(organization, item_function_post_form) ⇒ Object
Create item function.
-
#put_by_key(organization, key, item_function_put_form) ⇒ Object
Upsert item function.
Constructor Details
#initialize(client) ⇒ ItemFunctions
1909 1910 1911 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1909 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
Delete the item function with this key
1954 1955 1956 1957 1958 1959 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1954 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)}/item-functions/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
Search item functions. Always paginated.
1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1914 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) }), :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)}/item-functions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ItemFunction.new(x) } end |
#get_by_key(organization, key) ⇒ Object
Returns information about a specific item function.
1937 1938 1939 1940 1941 1942 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1937 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)}/item-functions/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::ItemFunction.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1962 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)}/item-functions/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ItemFunctionVersion.new(x) } end |
#post(organization, item_function_post_form) ⇒ Object
Create item function
1929 1930 1931 1932 1933 1934 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1929 def post(organization, item_function_post_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = item_function_post_form; x.is_a?(::Io::Flow::V0::Models::ItemFunctionPostForm) ? x : ::Io::Flow::V0::Models::ItemFunctionPostForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/item-functions").with_json(item_function_post_form.to_json).post ::Io::Flow::V0::Models::ItemFunction.new(r) end |
#put_by_key(organization, key, item_function_put_form) ⇒ Object
Upsert item function
1945 1946 1947 1948 1949 1950 1951 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1945 def put_by_key(organization, key, item_function_put_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = item_function_put_form; x.is_a?(::Io::Flow::V0::Models::ItemFunctionPutForm) ? x : ::Io::Flow::V0::Models::ItemFunctionPutForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/item-functions/#{CGI.escape(key)}").with_json(item_function_put_form.to_json).put ::Io::Flow::V0::Models::ItemFunction.new(r) end |