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.
1840 1841 1842 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1840 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
1882 1883 1884 1885 1886 1887 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1882 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
1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1844 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
1866 1867 1868 1869 1870 1871 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1866 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
1859 1860 1861 1862 1863 1864 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1859 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.
1874 1875 1876 1877 1878 1879 1880 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1874 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 |