Class: StarkBank::MerchantCountry

Inherits:
StarkCore::Utils::SubResource
  • Object
show all
Defined in:
lib/merchant_country/merchantcountry.rb

Overview

# MerchantCountry object

MerchantCountry’s codes are used to define countries filters in CorporateRules.

## Parameters (required):

  • code [string]: country’s code. ex: ‘BRA’

Attributes (return-only):

  • name [string]: country’s name. ex: ‘Brazil’

  • number [string]: country’s number. ex: ‘076’

  • short_code [string]: country’s short code. ex: ‘BR’

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, name: nil, number: nil, short_code: nil) ⇒ MerchantCountry

Returns a new instance of MerchantCountry.



20
21
22
23
24
25
# File 'lib/merchant_country/merchantcountry.rb', line 20

def initialize(code:, name: nil, number: nil, short_code: nil)
  @code = code
  @name = name
  @number = number
  @short_code = short_code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



19
20
21
# File 'lib/merchant_country/merchantcountry.rb', line 19

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/merchant_country/merchantcountry.rb', line 19

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



19
20
21
# File 'lib/merchant_country/merchantcountry.rb', line 19

def number
  @number
end

#short_codeObject (readonly)

Returns the value of attribute short_code.



19
20
21
# File 'lib/merchant_country/merchantcountry.rb', line 19

def short_code
  @short_code
end

Class Method Details

.query(search: nil, user: nil) ⇒ Object

# Retrieve MerchantCountries

Receive a generator of MerchantCountry 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 MerchantCountry objects with updated attributes



37
38
39
40
41
42
43
# File 'lib/merchant_country/merchantcountry.rb', line 37

def self.query(search: nil, user: nil)
  StarkBank::Utils::Rest.get_stream(
    search: search,
    user: user,
    **resource
  )
end

.resourceObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/merchant_country/merchantcountry.rb', line 45

def self.resource
  {
    resource_name: 'MerchantCountry',
    resource_maker: proc { |json|
      MerchantCountry.new(
        code: json['code'],
        name: json['name'],
        number: json['number'],
        short_code: json['short_code']
      )
    }
  }
end