Class: Io::Flow::V0::Clients::FraudEmailRules

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ FraudEmailRules

Returns a new instance of FraudEmailRules.



6937
6938
6939
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6937

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#delete_by_id(organization, id) ⇒ Object

Remove an email decision rule.



6966
6967
6968
6969
6970
6971
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6966

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)}/fraud/email/rules/#{CGI.escape(id)}").delete
  nil
end

#get(organization, incoming = {}) ⇒ Object

Retrieve fraud review email rules. Always paginated.



6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6942

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) }),
    :decision => (x = opts.delete(:decision); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::FraudEmailRuleDecision) ? x : ::Io::Flow::V0::Models::FraudEmailRuleDecision.apply(x)).value),
    :email => (x = opts.delete(:email); x.nil? ? nil : HttpClient::Preconditions.assert_class('email', x, 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? ? "decision" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/fraud/email/rules").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::FraudEmailRule.new(x) }
end

#post(organization, fraud_email_rule_form) ⇒ Object

Add an email decision rule.



6958
6959
6960
6961
6962
6963
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6958

def post(organization, fraud_email_rule_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = fraud_email_rule_form; x.is_a?(::Io::Flow::V0::Models::FraudEmailRuleForm) ? x : ::Io::Flow::V0::Models::FraudEmailRuleForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/fraud/email/rules").with_json(fraud_email_rule_form.to_json).post
  ::Io::Flow::V0::Models::FraudEmailRule.new(r)
end