Class: Io::Flow::V0::Clients::Centers
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Centers
- 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
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ Centers
constructor
A new instance of Centers.
- #post(organization, center_form) ⇒ Object
- #post_query(organization, center_query) ⇒ Object
- #put_by_key(organization, key, center_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ Centers
Returns a new instance of Centers.
3856 3857 3858 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3856 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
3917 3918 3919 3920 3921 3922 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3917 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)}/centers/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3860 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? ? "name" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/centers").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Center.new(x) } end |
#get_by_key(organization, key) ⇒ Object
3902 3903 3904 3905 3906 3907 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3902 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)}/centers/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::Center.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3888 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) }), :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? ? "journal_timestamp" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/centers/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::CenterVersion.new(x) } end |
#post(organization, center_form) ⇒ Object
3874 3875 3876 3877 3878 3879 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3874 def post(organization, center_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = center_form; x.is_a?(::Io::Flow::V0::Models::CenterForm) ? x : ::Io::Flow::V0::Models::CenterForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/centers").with_json(center_form.to_json).post ::Io::Flow::V0::Models::Center.new(r) end |
#post_query(organization, center_query) ⇒ Object
3881 3882 3883 3884 3885 3886 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3881 def post_query(organization, center_query) HttpClient::Preconditions.assert_class('organization', organization, String) (x = center_query; x.is_a?(::Io::Flow::V0::Models::CenterQuery) ? x : ::Io::Flow::V0::Models::CenterQuery.new(x)) r = @client.request("/#{CGI.escape(organization)}/centers/query").with_json(center_query.to_json).post r.map { |x| ::Io::Flow::V0::Models::Center.new(x) } end |
#put_by_key(organization, key, center_form) ⇒ Object
3909 3910 3911 3912 3913 3914 3915 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3909 def put_by_key(organization, key, center_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = center_form; x.is_a?(::Io::Flow::V0::Models::CenterForm) ? x : ::Io::Flow::V0::Models::CenterForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/centers/#{CGI.escape(key)}").with_json(center_form.to_json).put ::Io::Flow::V0::Models::Center.new(r) end |