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.
2305 2306 2307 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2305 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
2364 2365 2366 2367 2368 2369 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2364 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.
2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2310 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.
2347 2348 2349 2350 2351 2352 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2347 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
2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2333 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
2325 2326 2327 2328 2329 2330 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2325 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
2355 2356 2357 2358 2359 2360 2361 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2355 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 |