Class: StarkInfra::IssuingRule
- Inherits:
-
Utils::Resource
- Object
- Utils::SubResource
- Utils::Resource
- StarkInfra::IssuingRule
- Defined in:
- lib/issuingrule/issuingrule.rb
Overview
# IssuingRule object
The IssuingRule object displays the spending rules of IssuingCards and IssuingHolders created in your Workspace.
## Parameters (required):
-
name [string]: rule name. ex: ‘Travel’ or ‘Food’
-
amount [integer]: maximum amount that can be spent in the informed interval. ex: 200000 (= R$ 2000.00)
## Parameters (optional):
-
id [string, default nil]: unique id returned when Rule is created. ex: ‘5656565656565656’
-
interval [string, default ‘lifetime’]: interval after which the rule amount counter will be reset to 0. ex: ‘instant’, ‘day’, ‘week’, ‘month’, ‘year’ or ‘lifetime’
-
currency_code [string, default ‘BRL’]: code of the currency that the rule amount refers to. ex: ‘BRL’ or ‘USD’
-
categories [list of strings, default []]: merchant categories accepted by the rule. ex: [‘eatingPlacesRestaurants’, ‘travelAgenciesTourOperators’]
-
countries [list of strings, default []]: countries accepted by the rule. ex: [‘BRA’, ‘USA’]
-
methods [list of strings, default []]: card purchase methods accepted by the rule. ex: [‘chip’, ‘token’, ‘server’, ‘manual’, ‘magstripe’, ‘contactless’]
## Attributes (expanded return-only):
-
counter_amount [integer]: current rule spent amount. ex: 1000
-
currency_symbol [string]: currency symbol. ex: ‘R$’
-
currency_name [string]: currency name. ex: ‘Brazilian Real’
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#counter_amount ⇒ Object
readonly
Returns the value of attribute counter_amount.
-
#countries ⇒ Object
readonly
Returns the value of attribute countries.
-
#currency_code ⇒ Object
readonly
Returns the value of attribute currency_code.
-
#currency_name ⇒ Object
readonly
Returns the value of attribute currency_name.
-
#currency_symbol ⇒ Object
readonly
Returns the value of attribute currency_symbol.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Utils::Resource
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, amount:, id: nil, interval: nil, currency_code: nil, counter_amount: nil, currency_name: nil, currency_symbol: nil, categories: nil, countries: nil, methods: nil) ⇒ IssuingRule
constructor
A new instance of IssuingRule.
Methods inherited from Utils::SubResource
Constructor Details
#initialize(name:, amount:, id: nil, interval: nil, currency_code: nil, counter_amount: nil, currency_name: nil, currency_symbol: nil, categories: nil, countries: nil, methods: nil) ⇒ IssuingRule
Returns a new instance of IssuingRule.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/issuingrule/issuingrule.rb', line 28 def initialize(name:, amount:, id: nil, interval: nil, currency_code: nil, counter_amount: nil, currency_name: nil, currency_symbol: nil, categories: nil, countries: nil, methods: nil ) super(id) @name = name @interval = interval @amount = amount @currency_code = currency_code @counter_amount = counter_amount @currency_name = currency_name @currency_symbol = currency_symbol @categories = categories @countries = countries @methods = methods end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def amount @amount end |
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def categories @categories end |
#counter_amount ⇒ Object (readonly)
Returns the value of attribute counter_amount.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def counter_amount @counter_amount end |
#countries ⇒ Object (readonly)
Returns the value of attribute countries.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def countries @countries end |
#currency_code ⇒ Object (readonly)
Returns the value of attribute currency_code.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def currency_code @currency_code end |
#currency_name ⇒ Object (readonly)
Returns the value of attribute currency_name.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def currency_name @currency_name end |
#currency_symbol ⇒ Object (readonly)
Returns the value of attribute currency_symbol.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def currency_symbol @currency_symbol end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def interval @interval end |
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def methods @methods end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/issuingrule/issuingrule.rb', line 27 def name @name end |
Class Method Details
.parse_rules(rules) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/issuingrule/issuingrule.rb', line 44 def self.parse_rules(rules) rule_maker = StarkInfra::IssuingRule.resource[:resource_maker] return rules if rules.nil? parsed_rules = [] rules.each do |rule| unless rule.is_a? IssuingRule rule = StarkInfra::Utils::API.from_api_json(rule_maker, rule) end parsed_rules << rule end parsed_rules end |
.resource ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/issuingrule/issuingrule.rb', line 58 def self.resource { resource_name: 'IssuingRule', resource_maker: proc { |json| IssuingRule.new( name: json['name'], interval: json['interval'], amount: json['amount'], currency_code: json['currency_code'], counter_amount: json['counter_amount'], currency_name: json['currency_name'], currency_symbol: json['currency_symbol'], categories: json['categories'], countries: json['countries'], methods: json['methods'] ) } } end |