Class: StarkBank::CardMethod
- Inherits:
-
StarkCore::Utils::SubResource
- Object
- StarkCore::Utils::SubResource
- StarkBank::CardMethod
- Defined in:
- lib/card_method/cardmethod.rb
Overview
# CardMethod object
CardMethod’s codes are used to define method filters in CorporateRules.
## Parameters (required):
-
code [string]: method’s code. Options: ‘chip’, ‘token’, ‘server’, ‘manual’, ‘magstripe’, ‘contactless’
Attributes (return-only):
-
name [string]: method’s name. ex: ‘token’
-
number [string]: method’s number. ex: ‘81’
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Class Method Summary collapse
-
.query(search: nil, user: nil) ⇒ Object
# Retrieve CardMethods.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(code:, name: nil, number: nil) ⇒ CardMethod
constructor
A new instance of CardMethod.
Constructor Details
#initialize(code:, name: nil, number: nil) ⇒ CardMethod
Returns a new instance of CardMethod.
19 20 21 22 23 |
# File 'lib/card_method/cardmethod.rb', line 19 def initialize(code:, name: nil, number: nil) @code = code @name = name @number = number end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
18 19 20 |
# File 'lib/card_method/cardmethod.rb', line 18 def code @code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/card_method/cardmethod.rb', line 18 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
18 19 20 |
# File 'lib/card_method/cardmethod.rb', line 18 def number @number end |
Class Method Details
.query(search: nil, user: nil) ⇒ Object
# Retrieve CardMethods
Receive a generator of CardMethod objects available in the Stark Bank API
## Parameters (optional):
-
search [string, default nil]: keyword to search for code, name, number or short_code
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
## Return:
-
generator of CardMethod objects with updated attributes
35 36 37 38 39 40 41 |
# File 'lib/card_method/cardmethod.rb', line 35 def self.query(search: nil, user: nil) StarkBank::Utils::Rest.get_stream( search: search, user: user, **resource ) end |
.resource ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/card_method/cardmethod.rb', line 43 def self.resource { resource_name: 'CardMethod', resource_maker: proc { |json| CardMethod.new( code: json['code'], name: json['name'], number: json['number'] ) } } end |