Class: StarkInfra::MerchantCategory

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

Overview

# MerchantCategory object

MerchantCategory’s codes and types are used to define categories filters in IssuingRules.

A MerchantCategory filter must define exactly one parameter between code and type. A type, such as ‘food’, ‘services’, etc., defines an entire group of merchant codes, whereas a code only specifies a specific MCC.

## Parameters (conditionally required):

  • code [string, default nil]: category’s code. ex: ‘veterinaryServices’, ‘fastFoodRestaurants’

  • type [string, default nil]: category’s type. ex: ‘pets’, ‘food’

Attributes (return-only):

  • name [string]: category’s name. ex: ‘Veterinary services’, ‘Fast food restaurants’

  • number [string]: category’s number. ex: ‘742’, ‘5814’

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, type:, name: nil, number: nil) ⇒ MerchantCategory

Returns a new instance of MerchantCategory.



24
25
26
27
28
29
# File 'lib/merchantcategory/merchantcategory.rb', line 24

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



23
24
25
# File 'lib/merchantcategory/merchantcategory.rb', line 23

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



23
24
25
# File 'lib/merchantcategory/merchantcategory.rb', line 23

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



23
24
25
# File 'lib/merchantcategory/merchantcategory.rb', line 23

def number
  @number
end

#typeObject (readonly)

Returns the value of attribute type.



23
24
25
# File 'lib/merchantcategory/merchantcategory.rb', line 23

def type
  @type
end

Class Method Details

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

# Retrieve MerchantCategories

Receive a generator of MerchantCategory objects available in the Stark Infra 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 starkinfra.user was set before function call

## Return:

  • generator of MerchantCategory objects with updated attributes



41
42
43
44
45
46
47
# File 'lib/merchantcategory/merchantcategory.rb', line 41

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

.resourceObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/merchantcategory/merchantcategory.rb', line 49

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