Class: Io::Flow::V0::Clients::DiscountRuleSettings
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::DiscountRuleSettings
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(organization, id) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
-
#initialize(client) ⇒ DiscountRuleSettings
constructor
A new instance of DiscountRuleSettings.
- #post(organization, discount_rule_settings_form) ⇒ Object
- #put_by_id(organization, id, discount_rule_settings_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ DiscountRuleSettings
Returns a new instance of DiscountRuleSettings.
1140 1141 1142 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1140 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
1180 1181 1182 1183 1184 1185 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1180 def delete_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/discount/rule/settings/#{CGI.escape(id)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1144 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) }), :status => (x = opts.delete(:status); x.nil? ? nil : HttpClient::Preconditions.assert_class('status', x, Array).map { |v| HttpClient::Preconditions.assert_class('status', 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)}/discount/rule/settings").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::DiscountRuleSettings.new(x) } end |
#get_by_id(organization, id) ⇒ Object
1165 1166 1167 1168 1169 1170 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1165 def get_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/discount/rule/settings/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::DiscountRuleSettings.new(r) end |
#post(organization, discount_rule_settings_form) ⇒ Object
1158 1159 1160 1161 1162 1163 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1158 def post(organization, discount_rule_settings_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = discount_rule_settings_form; x.is_a?(::Io::Flow::V0::Models::DiscountRuleSettingsForm) ? x : ::Io::Flow::V0::Models::DiscountRuleSettingsForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/discount/rule/settings").with_json(discount_rule_settings_form.to_json).post ::Io::Flow::V0::Models::DiscountRuleSettings.new(r) end |
#put_by_id(organization, id, discount_rule_settings_form) ⇒ Object
1172 1173 1174 1175 1176 1177 1178 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1172 def put_by_id(organization, id, discount_rule_settings_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) (x = discount_rule_settings_form; x.is_a?(::Io::Flow::V0::Models::DiscountRuleSettingsForm) ? x : ::Io::Flow::V0::Models::DiscountRuleSettingsForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/discount/rule/settings/#{CGI.escape(id)}").with_json(discount_rule_settings_form.to_json).put ::Io::Flow::V0::Models::DiscountRuleSettings.new(r) end |