Class: StarkInfra::IssuingHolder
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkInfra::IssuingHolder
- Defined in:
- lib/issuingholder/issuingholder.rb,
lib/issuingholder/log.rb
Overview
# IssuingHolder object
The IssuingHolder describes a card holder that may group several cards.
When you initialize a IssuingHolder, the entity will not be automatically created in the Stark Infra API. The ‘create’ function sends the objects to the Stark Infra API and returns the created object.
## Parameters (required):
-
name [string]: card holder name.
-
tax_id [string]: card holder tax ID
-
external_id [string] card holder external ID
## Parameters (optional):
-
rules [list of IssuingRule objects, default nil]: [EXPANDABLE] list of holder spending rules.
-
tags [list of strings, default nil]: list of strings for tagging. ex: [‘travel’, ‘food’]
## Attributes (return-only):
-
id [string]: unique id returned when IssuingHolder is created. ex: ‘5656565656565656’
-
status [string]: current IssuingHolder status. ex: ‘active’, ‘blocked’, ‘canceled’
-
updated [DateTime]: latest update datetime for the IssuingHolder. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Defined Under Namespace
Classes: Log
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#tax_id ⇒ Object
readonly
Returns the value of attribute tax_id.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.cancel(id, user: nil) ⇒ Object
# Cancel an IssuingHolder entity.
-
.create(holders:, expand: nil, user: nil) ⇒ Object
# Create IssuingHolders.
-
.get(id, expand: nil, user: nil) ⇒ Object
# Retrieve a specific IssuingHolder.
-
.page(cursor: nil, limit: nil, ids: nil, after: nil, before: nil, status: nil, tags: nil, expand: nil, user: nil) ⇒ Object
# Retrieve paged IssuingHolders.
-
.query(limit: nil, ids: nil, after: nil, before: nil, status: nil, tags: nil, expand: nil, user: nil) ⇒ Object
# Retrieve IssuingHolders.
- .resource ⇒ Object
-
.update(id, status: nil, name: nil, tags: nil, rules: nil, user: nil) ⇒ Object
# Update IssuingHolder entity.
Instance Method Summary collapse
-
#initialize(name:, tax_id:, external_id:, rules: nil, tags: nil, id: nil, status: nil, updated: nil, created: nil) ⇒ IssuingHolder
constructor
A new instance of IssuingHolder.
Constructor Details
#initialize(name:, tax_id:, external_id:, rules: nil, tags: nil, id: nil, status: nil, updated: nil, created: nil) ⇒ IssuingHolder
Returns a new instance of IssuingHolder.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/issuingholder/issuingholder.rb', line 31 def initialize( name:, tax_id:, external_id:, rules: nil, tags: nil, id: nil, status: nil, updated: nil, created: nil ) super(id) @name = name @tax_id = tax_id @external_id = external_id @rules = StarkInfra::IssuingRule.parse_rules(rules) @tags = @status = status @created = StarkCore::Utils::Checks.check_datetime(created) @updated = StarkCore::Utils::Checks.check_datetime(updated) end |
Instance Attribute Details
#created ⇒ Object (readonly)
Returns the value of attribute created.
30 31 32 |
# File 'lib/issuingholder/issuingholder.rb', line 30 def created @created end |
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id.
30 31 32 |
# File 'lib/issuingholder/issuingholder.rb', line 30 def external_id @external_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
30 31 32 |
# File 'lib/issuingholder/issuingholder.rb', line 30 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
30 31 32 |
# File 'lib/issuingholder/issuingholder.rb', line 30 def name @name end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
30 31 32 |
# File 'lib/issuingholder/issuingholder.rb', line 30 def rules @rules end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
30 31 32 |
# File 'lib/issuingholder/issuingholder.rb', line 30 def status @status end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
30 31 32 |
# File 'lib/issuingholder/issuingholder.rb', line 30 def @tags end |
#tax_id ⇒ Object (readonly)
Returns the value of attribute tax_id.
30 31 32 |
# File 'lib/issuingholder/issuingholder.rb', line 30 def tax_id @tax_id end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
30 31 32 |
# File 'lib/issuingholder/issuingholder.rb', line 30 def updated @updated end |
Class Method Details
.cancel(id, user: nil) ⇒ Object
# Cancel an IssuingHolder entity
Cancel an IssuingHolder entity previously created in the Stark Infra API
## Parameters (required):
-
id [string]: IssuingHolder unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
canceled IssuingHolder object
188 189 190 |
# File 'lib/issuingholder/issuingholder.rb', line 188 def self.cancel(id, user: nil) StarkCore::Utils::Rest.delete_id(id: id, user: user, **resource) end |
.create(holders:, expand: nil, user: nil) ⇒ Object
# Create IssuingHolders
Send a list of IssuingHolder objects for creation in the Stark Infra API
## Parameters (required):
-
holders [list of IssuingHolder objects]: list of IssuingHolder objects to be created in the API
## Parameters (optional):
-
expand [list of strings, default nil]: fields to expand information. Options: [‘rules’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
list of IssuingHolder objects with updated attributes
58 59 60 |
# File 'lib/issuingholder/issuingholder.rb', line 58 def self.create(holders:, expand: nil, user: nil) StarkInfra::Utils::Rest.post(entities: holders, expand: , user: user, **resource) end |
.get(id, expand: nil, user: nil) ⇒ Object
# Retrieve a specific IssuingHolder
Receive a single IssuingHolder object previously created in the Stark Infra API by its id
## Parameters (required):
-
id [string]: object unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
expand [list of strings, default nil]: fields to expand information. ex: [‘rules’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
## Return:
-
IssuingHolder object with updated attributes
75 76 77 |
# File 'lib/issuingholder/issuingholder.rb', line 75 def self.get(id, expand: nil, user: nil) StarkInfra::Utils::Rest.get_id(id: id, expand: , user: user, **resource) end |
.page(cursor: nil, limit: nil, ids: nil, after: nil, before: nil, status: nil, tags: nil, expand: nil, user: nil) ⇒ Object
# Retrieve paged IssuingHolders
Receive a list of up to 100 IssuingHolders objects previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your logs.
## Parameters (optional):
-
cursor [string, default nil]: cursor returned on the previous page function call.
-
limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
-
after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
-
status [list of strings, default nil]: filter for status of retrieved objects. ex: [‘active’, ‘blocked’, ‘canceled’]
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]
-
expand [string, default nil]: fields to expand information. ex: [‘rules’]
-
ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: [‘5656565656565656’, ‘4545454545454545’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
## Return:
-
list of IssuingHolders objects with updated attributes
-
cursor to retrieve the next page of IssuingHolders objects
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/issuingholder/issuingholder.rb', line 130 def self.page(cursor: nil, limit: nil, ids: nil, after: nil, before: nil, status: nil, tags: nil, expand: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_page( cursor: cursor, limit: limit, ids: ids, after: after, before: before, status: status, tags: , expand: , user: user, **resource ) end |
.query(limit: nil, ids: nil, after: nil, before: nil, status: nil, tags: nil, expand: nil, user: nil) ⇒ Object
# Retrieve IssuingHolders
Receive a generator of IssuingHolder objects previously created in the Stark Infra API
## Parameters (optional):
-
limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
-
after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
-
status [list of strings, default nil]: filter for status of retrieved objects. ex: [‘active’, ‘blocked’, ‘canceled’]
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]
-
expand [string, default nil]: fields to expand information. ex: [‘rules’]
-
ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: [‘5656565656565656’, ‘4545454545454545’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
## Return:
-
generator of IssuingHolders objects with updated attributes
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/issuingholder/issuingholder.rb', line 95 def self.query(limit: nil, ids: nil, after: nil, before: nil, status: nil, tags: nil, expand: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_stream( limit: limit, ids: ids, after: after, before: before, status: status, tags: , expand: , user: user, **resource ) end |
.resource ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/issuingholder/issuingholder.rb', line 192 def self.resource { resource_name: 'IssuingHolder', resource_maker: proc { |json| IssuingHolder.new( id: json['id'], name: json['name'], tax_id: json['tax_id'], external_id: json['external_id'], rules: json['rules'], tags: json['tags'], status: json['status'], updated: json['updated'], created: json['created'] ) } } end |
.update(id, status: nil, name: nil, tags: nil, rules: nil, user: nil) ⇒ Object
# Update IssuingHolder entity
Update an IssuingHolder by passing id, if it hasn’t been paid yet.
## Parameters (required):
-
id [string]: IssuingHolder id. ex: ‘5656565656565656’
## Parameters (optional):
-
status [string, default nil]: You may block the IssuingHolder by passing ‘blocked’ in the status
-
name [string, default nil]: card holder name.
-
tags [list of strings, default nil]: list of strings for tagging
-
rules [list of IssuingRule objects, default nil]: list of objects that represent the holder’s spending rules.
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
## Return:
-
target IssuingHolder with updated attributes
164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/issuingholder/issuingholder.rb', line 164 def self.update(id, status: nil, name: nil, tags: nil, rules: nil, user: nil) StarkInfra::Utils::Rest.patch_id( id: id, status: status, name: name, tags: , rules: rules, user: user, **resource ) end |