Class: StarkBank::CorporateCard
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkBank::CorporateCard
- Defined in:
- lib/corporate_card/corporatecard.rb,
lib/corporate_card/log.rb
Overview
# CorporateCard object
The CorporateCard object displays the information of the cards created in your Workspace. Sensitive information will only be returned when the ‘expand’ parameter is used, to avoid security concerns.
When you initialize a CorporateCard, the entity will not be automatically created in the Stark Bank API. The ‘create’ function sends the objects to the Stark Bank API and returns the created object.
## Parameters (required):
-
holder_id [string]: card holder tax ID. ex: ‘012.345.678-90’
## Attributes (return-only):
-
id [string]: unique id returned when CorporateCard is created. ex: ‘5656565656565656’
-
holder_name [string, default nil]: card holder name. ex: ‘Tony Stark’
-
display_name [string, default nil]: card displayed name. ex: ‘ANTHONY STARK’
-
rules [list of CorporateRule objects, default nil]: [EXPANDABLE] list of card spending rules.
-
tags [list of strings, default nil]: list of strings for tagging. ex: [‘travel’, ‘food’]
-
street_line_1 [string, default sub-issuer street line 1]: card holder main address. ex: ‘Av. Paulista, 200’
-
street_line_2 [string, default sub-issuer street line 2]: card holder address complement. ex: ‘Apto. 123’
-
district [string, default sub-issuer district]: card holder address district / neighbourhood. ex: ‘Bela Vista’
-
city [string, default sub-issuer city]: card holder address city. ex: ‘Rio de Janeiro’
-
state_code [string, default sub-issuer state code]: card holder address state. ex: ‘GO’
-
zip_code [string, default sub-issuer zip code]: card holder address zip code. ex: ‘01311-200’
-
type [string]: card type. ex: ‘virtual’
-
status [string]: current CorporateCard status. ex: ‘active’, ‘blocked’, ‘canceled’, ‘expired’.
-
number [string]: [EXPANDABLE] masked card number. Expand to unmask the value. ex: ‘123’.
-
security_code [string]: [EXPANDABLE] masked card verification value (cvv). Expand to unmask the value. ex: ‘123’.
-
expiration [DateTime]: [EXPANDABLE] masked card expiration datetime. Expand to unmask the value. ex: DateTime.new(2032, 3, 10, 10, 30, 0, 0)
-
created [DateTime]: creation datetime for the CorporateCard. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
updated [DateTime]: latest update datetime for the CorporateCard. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Defined Under Namespace
Classes: Log
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#district ⇒ Object
readonly
Returns the value of attribute district.
-
#expiration ⇒ Object
readonly
Returns the value of attribute expiration.
-
#holder_id ⇒ Object
readonly
Returns the value of attribute holder_id.
-
#holder_name ⇒ Object
readonly
Returns the value of attribute holder_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#security_code ⇒ Object
readonly
Returns the value of attribute security_code.
-
#state_code ⇒ Object
readonly
Returns the value of attribute state_code.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#street_line_1 ⇒ Object
readonly
Returns the value of attribute street_line_1.
-
#street_line_2 ⇒ Object
readonly
Returns the value of attribute street_line_2.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
-
#zip_code ⇒ Object
readonly
Returns the value of attribute zip_code.
Class Method Summary collapse
-
.cancel(id, user: nil) ⇒ Object
# Cancel a CorporateCard entity.
-
.create(card:, expand: nil, user: nil) ⇒ Object
# Create CorporateCards.
-
.get(id, expand: nil, user: nil) ⇒ Object
# Retrieve a specific CorporateCard.
-
.page(cursor: nil, limit: nil, ids: nil, after: nil, before: nil, status: nil, types: nil, holder_ids: nil, tags: nil, expand: nil, user: nil) ⇒ Object
# Retrieve paged CorporateCards.
-
.query(limit: nil, ids: nil, after: nil, before: nil, status: nil, types: nil, holder_ids: nil, tags: nil, expand: nil, user: nil) ⇒ Object
# Retrieve CorporateCards.
- .resource ⇒ Object
-
.update(id, status: nil, display_name: nil, pin: nil, rules: nil, tags: nil, user: nil) ⇒ Object
# Update CorporateCard entity.
Instance Method Summary collapse
-
#initialize(holder_id:, holder_name: nil, display_name: nil, rules: nil, tags: nil, street_line_1: nil, street_line_2: nil, district: nil, city: nil, state_code: nil, zip_code: nil, id: nil, type: nil, status: nil, number: nil, security_code: nil, expiration: nil, created: nil, updated: nil) ⇒ CorporateCard
constructor
A new instance of CorporateCard.
Constructor Details
#initialize(holder_id:, holder_name: nil, display_name: nil, rules: nil, tags: nil, street_line_1: nil, street_line_2: nil, district: nil, city: nil, state_code: nil, zip_code: nil, id: nil, type: nil, status: nil, number: nil, security_code: nil, expiration: nil, created: nil, updated: nil) ⇒ CorporateCard
Returns a new instance of CorporateCard.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/corporate_card/corporatecard.rb', line 42 def initialize( holder_id:, holder_name: nil, display_name: nil, rules: nil, tags: nil, street_line_1: nil, street_line_2: nil, district: nil, city: nil, state_code: nil, zip_code: nil, id: nil, type: nil, status: nil, number: nil, security_code: nil, expiration: nil, created: nil, updated: nil ) super(id) @holder_id = holder_id @holder_name = holder_name @display_name = display_name @rules = StarkBank::CorporateRule.parse_rules(rules) @tags = @street_line_1 = street_line_1 @street_line_2 = street_line_2 @district = district @city = city @state_code = state_code @zip_code = zip_code @type = type @status = status @number = number @security_code = security_code expiration = nil if !expiration.nil? && expiration.include?('*') @expiration = StarkCore::Utils::Checks.check_datetime(expiration) @created = StarkCore::Utils::Checks.check_datetime(created) @updated = StarkCore::Utils::Checks.check_datetime(updated) end |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def city @city end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def created @created end |
#display_name ⇒ Object (readonly)
Returns the value of attribute display_name.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def display_name @display_name end |
#district ⇒ Object (readonly)
Returns the value of attribute district.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def district @district end |
#expiration ⇒ Object (readonly)
Returns the value of attribute expiration.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def expiration @expiration end |
#holder_id ⇒ Object (readonly)
Returns the value of attribute holder_id.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def holder_id @holder_id end |
#holder_name ⇒ Object (readonly)
Returns the value of attribute holder_name.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def holder_name @holder_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def id @id end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def number @number end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def rules @rules end |
#security_code ⇒ Object (readonly)
Returns the value of attribute security_code.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def security_code @security_code end |
#state_code ⇒ Object (readonly)
Returns the value of attribute state_code.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def state_code @state_code end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def status @status end |
#street_line_1 ⇒ Object (readonly)
Returns the value of attribute street_line_1.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def street_line_1 @street_line_1 end |
#street_line_2 ⇒ Object (readonly)
Returns the value of attribute street_line_2.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def street_line_2 @street_line_2 end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def @tags end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def type @type end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def updated @updated end |
#zip_code ⇒ Object (readonly)
Returns the value of attribute zip_code.
39 40 41 |
# File 'lib/corporate_card/corporatecard.rb', line 39 def zip_code @zip_code end |
Class Method Details
.cancel(id, user: nil) ⇒ Object
# Cancel a CorporateCard entity
Cancel a CorporateCard entity previously created in the Stark Bank API
## Parameters (required):
-
id [string]: CorporateCard unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
canceled CorporateCard object
226 227 228 |
# File 'lib/corporate_card/corporatecard.rb', line 226 def self.cancel(id, user: nil) StarkBank::Utils::Rest.delete_id(id: id, user: user, **resource) end |
.create(card:, expand: nil, user: nil) ⇒ Object
# Create CorporateCards
Send a CorporateCard object for creation in the Stark Bank API
## Parameters (required):
-
card [CorporateCard object]: CorporateCard object to be created in the API
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
CorporateCard object with updated attributes
81 82 83 84 85 86 87 |
# File 'lib/corporate_card/corporatecard.rb', line 81 def self.create(card:, expand: nil, user: nil) path = StarkCore::Utils::API.endpoint(resource[:resource_name]) + '/token' payload = StarkCore::Utils::API.api_json(card) json = StarkBank::Utils::Rest.post_raw(path: path, payload: payload, expand: , user: user) entity_json = json[StarkCore::Utils::API.last_name(resource[:resource_name])] StarkCore::Utils::API.from_api_json(resource[:resource_maker], entity_json) end |
.get(id, expand: nil, user: nil) ⇒ Object
# Retrieve a specific CorporateCard
Receive a single CorporateCard object previously created in the Stark Bank 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’, ‘securityCode’, ‘number’, ‘expiration’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
CorporateCard object with updated attributes
102 103 104 |
# File 'lib/corporate_card/corporatecard.rb', line 102 def self.get(id, expand: nil, user: nil) StarkBank::Utils::Rest.get_id(id: id, expand: , user: user, **resource) end |
.page(cursor: nil, limit: nil, ids: nil, after: nil, before: nil, status: nil, types: nil, holder_ids: nil, tags: nil, expand: nil, user: nil) ⇒ Object
# Retrieve paged CorporateCards
Receive a list of up to 100 CorporateCard objects previously created in the Stark Bank API and the cursor to the next page. Use this function instead of query if you want to manually page your identities.
## 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’, ‘expired’]
-
types [list of strings, default nil]: card type. ex: [‘virtual’]
-
holder_ids [list of strings, default nil]: card holder IDs. ex: [‘5656565656565656’, ‘4545454545454545’]
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]
-
expand [list of strings, default nil]: fields to expand information. ex: [‘rules’, ‘security_code’, ‘number’, ‘expiration’]
-
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 StarkBank.user was set before function call
## Return:
-
list of CorporateCard objects with updated attributes
-
cursor to retrieve the next page of CorporateCards objects
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/corporate_card/corporatecard.rb', line 164 def self.page(cursor: nil, limit: nil, ids: nil, after: nil, before: nil, status: nil, types: nil, holder_ids: nil, tags: nil, expand: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkBank::Utils::Rest.get_page( cursor: cursor, limit: limit, ids: ids, after: after, before: before, status: status, types: types, holder_ids: holder_ids, tags: , expand: , user: user, **resource ) end |
.query(limit: nil, ids: nil, after: nil, before: nil, status: nil, types: nil, holder_ids: nil, tags: nil, expand: nil, user: nil) ⇒ Object
# Retrieve CorporateCards
Receive a generator of CorporateCard objects previously created in the Stark Bank 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’, ‘expired’]
-
types [list of strings, default nil]: card type. ex: [‘virtual’]
-
holder_ids [list of strings, default nil]: card holder IDs. ex: [‘5656565656565656’, ‘4545454545454545’]
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]
-
expand [list of strings, default nil]: fields to expand information. ex: [‘rules’, ‘security_code’, ‘number’, ‘expiration’]
-
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 StarkBank.user was set before function call
## Return:
-
generator of CorporateCards objects with updated attributes
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/corporate_card/corporatecard.rb', line 124 def self.query(limit: nil, ids: nil, after: nil, before: nil, status: nil, types: nil, holder_ids: nil, tags: nil, expand: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkBank::Utils::Rest.get_stream( limit: limit, ids: ids, after: after, before: before, status: status, types: types, holder_ids: holder_ids, tags: , expand: , user: user, **resource ) end |
.resource ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/corporate_card/corporatecard.rb', line 230 def self.resource { resource_name: 'CorporateCard', resource_maker: proc { |json| CorporateCard.new( holder_id: json['holder_id'], id: json['id'], holder_name: json['holder_name'], display_name: json['display_name'], rules: json['rules'], tags: json['tags'], street_line_1: json['street_line_1'], street_line_2: json['street_line_2'], district: json['district'], city: json['city'], state_code: json['state_code'], zip_code: json['zip_code'], type: json['type'], status: json['status'], number: json['number'], security_code: json['security_code'], expiration: json['expiration'], created: json['created'], updated: json['updated'] ) } } end |
.update(id, status: nil, display_name: nil, pin: nil, rules: nil, tags: nil, user: nil) ⇒ Object
# Update CorporateCard entity
Update a CorporateCard by passing id.
## Parameters (required):
-
id [string]: CorporateCard unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
status [string, default nil]: You may block the CorporateCard by passing ‘blocked’ or activate by passing ‘active’ in the status
-
pin [string, default nil]: You may unlock your physical card by passing its PIN. This is also the PIN you use to authorize a purchase.
-
display_name [string, default nil]: card displayed name. ex: “ANTHONY EDWARD”
-
rules [list of CorporateRule objects, default nil]: [EXPANDABLE] list of card spending rules.
-
tags [list of strings, default nil]: list of strings for tagging
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
## Return:
-
target CorporateCard with updated attributes
201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/corporate_card/corporatecard.rb', line 201 def self.update(id, status: nil, display_name: nil,pin: nil, rules: nil, tags: nil, user: nil) StarkBank::Utils::Rest.patch_id( id: id, status: status, pin: pin, display_name: display_name, rules: rules, tags: , user: user, **resource ) end |