Class: Io::Flow::V0::Clients::PriceBookItems
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::PriceBookItems
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_key(organization, price_book_key, key) ⇒ Object
Deletes the specified price book item.
- #get(organization, price_book_key, incoming = {}) ⇒ Object
-
#get_by_key(organization, price_book_key, key) ⇒ Object
Returns information about a specific price book item.
-
#initialize(client) ⇒ PriceBookItems
constructor
A new instance of PriceBookItems.
-
#post(organization, price_book_key, price_book_item_form) ⇒ Object
Create a price book item.
-
#put_by_key(organization, price_book_key, key, price_book_item_form) ⇒ Object
Create or update a price book item.
Constructor Details
#initialize(client) ⇒ PriceBookItems
Returns a new instance of PriceBookItems.
2937 2938 2939 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2937 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, price_book_key, key) ⇒ Object
Deletes the specified price book item
2986 2987 2988 2989 2990 2991 2992 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2986 def delete_by_key(organization, price_book_key, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('price_book_key', price_book_key, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/price/books/#{CGI.escape(price_book_key)}/items/#{CGI.escape(key)}").delete nil end |
#get(organization, price_book_key, incoming = {}) ⇒ Object
2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2941 def get(organization, price_book_key, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('price_book_key', price_book_key, 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) }), :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? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/price/books/#{CGI.escape(price_book_key)}/items").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::PriceBookItem.new(x) } end |
#get_by_key(organization, price_book_key, key) ⇒ Object
Returns information about a specific price book item.
2967 2968 2969 2970 2971 2972 2973 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2967 def get_by_key(organization, price_book_key, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('price_book_key', price_book_key, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/price/books/#{CGI.escape(price_book_key)}/items/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::PriceBookItem.new(r) end |
#post(organization, price_book_key, price_book_item_form) ⇒ Object
Create a price book item.
2958 2959 2960 2961 2962 2963 2964 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2958 def post(organization, price_book_key, price_book_item_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('price_book_key', price_book_key, String) (x = price_book_item_form; x.is_a?(::Io::Flow::V0::Models::PriceBookItemForm) ? x : ::Io::Flow::V0::Models::PriceBookItemForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/price/books/#{CGI.escape(price_book_key)}/items").with_json(price_book_item_form.to_json).post ::Io::Flow::V0::Models::PriceBookItem.new(r) end |
#put_by_key(organization, price_book_key, key, price_book_item_form) ⇒ Object
Create or update a price book item.
2976 2977 2978 2979 2980 2981 2982 2983 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2976 def put_by_key(organization, price_book_key, key, price_book_item_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('price_book_key', price_book_key, String) HttpClient::Preconditions.assert_class('key', key, String) (x = price_book_item_form; x.is_a?(::Io::Flow::V0::Models::PriceBookItemForm) ? x : ::Io::Flow::V0::Models::PriceBookItemForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/price/books/#{CGI.escape(price_book_key)}/items/#{CGI.escape(key)}").with_json(price_book_item_form.to_json).put ::Io::Flow::V0::Models::PriceBookItem.new(r) end |