Class: Io::Flow::V0::Clients::ItemFormOverlays
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::ItemFormOverlays
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_key(organization, key) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_key(organization, key) ⇒ Object
-
#initialize(client) ⇒ ItemFormOverlays
constructor
A new instance of ItemFormOverlays.
-
#post(organization, item_form_overlay_form) ⇒ Object
Adds an overlay data to merge into a catalog item.
-
#put_by_key(organization, key, item_form_overlay_form) ⇒ Object
Update item overlay with the specified key, creating if it does not exist.
Constructor Details
#initialize(client) ⇒ ItemFormOverlays
Returns a new instance of ItemFormOverlays.
1744 1745 1746 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1744 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
1786 1787 1788 1789 1790 1791 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1786 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)}/catalog/item/overlays/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1748 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? ? "position" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/catalog/item/overlays").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ItemFormOverlay.new(x) } end |
#get_by_key(organization, key) ⇒ Object
1770 1771 1772 1773 1774 1775 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1770 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)}/catalog/item/overlays/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::ItemFormOverlay.new(r) end |
#post(organization, item_form_overlay_form) ⇒ Object
Adds an overlay data to merge into a catalog item
1763 1764 1765 1766 1767 1768 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1763 def post(organization, ) HttpClient::Preconditions.assert_class('organization', organization, String) (x = ; x.is_a?(::Io::Flow::V0::Models::ItemFormOverlayForm) ? x : ::Io::Flow::V0::Models::ItemFormOverlayForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/catalog/item/overlays").with_json(.to_json).post ::Io::Flow::V0::Models::ItemFormOverlay.new(r) end |
#put_by_key(organization, key, item_form_overlay_form) ⇒ Object
Update item overlay with the specified key, creating if it does not exist.
1778 1779 1780 1781 1782 1783 1784 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1778 def put_by_key(organization, key, ) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = ; x.is_a?(::Io::Flow::V0::Models::ItemFormOverlayForm) ? x : ::Io::Flow::V0::Models::ItemFormOverlayForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/catalog/item/overlays/#{CGI.escape(key)}").with_json(.to_json).put ::Io::Flow::V0::Models::ItemFormOverlay.new(r) end |