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
Returns a new instance of ItemFunctions.
1859 1860 1861 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1859 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
1904 1905 1906 1907 1908 1909 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1904 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.
1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1864 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.
1887 1888 1889 1890 1891 1892 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1887 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
1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1912 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
1879 1880 1881 1882 1883 1884 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1879 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
1895 1896 1897 1898 1899 1900 1901 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1895 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 |