Class: StarkInfra::IssuingWithdrawal

Inherits:
Utils::Resource show all
Defined in:
lib/issuingwithdrawal/issuingwithdrawal.rb

Overview

# IssuingWithdrawal object

The IssuingWithdrawal objects created in your Workspace return cash from your Issuing balance to your Banking balance.

## Parameters (required):

  • amount [integer]: IssuingWithdrawal value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34)

  • external_id [string] IssuingWithdrawal external ID. ex: ‘12345’

  • description [string]: IssuingWithdrawal description. ex: ‘sending money back’

## Parameters (optional):

  • tags [list of strings, default []]: list of strings for tagging. ex: [‘tony’, ‘stark’]

## Attributes (return-only):

  • id [string]: unique id returned when IssuingWithdrawal is created. ex: ‘5656565656565656’

  • transaction_id [string]: Stark Bank ledger transaction ids linked to this IssuingWithdrawal

  • issuing_transaction_id [string]: issuing ledger transaction ids linked to this IssuingWithdrawal

  • updated [DateTime]: latest update datetime for the IssuingWithdrawal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)

  • created [DateTime]: creation datetime for the IssuingWithdrawal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Utils::SubResource

#inspect, #to_s

Constructor Details

#initialize(amount:, external_id:, description:, tags: nil, id: nil, transaction_id: nil, issuing_transaction_id: nil, updated: nil, created: nil) ⇒ IssuingWithdrawal

Returns a new instance of IssuingWithdrawal.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 28

def initialize(
  amount:, external_id:, description:, tags: nil, id: nil, transaction_id: nil, issuing_transaction_id: nil,
  updated: nil, created: nil
)
  super(id)
  @amount = amount
  @external_id = external_id
  @description = description
  @tags = tags
  @transaction_id = transaction_id
  @issuing_transaction_id = issuing_transaction_id
  @created = StarkInfra::Utils::Checks.check_datetime(created)
  @updated = StarkInfra::Utils::Checks.check_datetime(updated)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



27
28
29
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 27

def amount
  @amount
end

#createdObject (readonly)

Returns the value of attribute created.



27
28
29
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 27

def created
  @created
end

#descriptionObject (readonly)

Returns the value of attribute description.



27
28
29
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 27

def description
  @description
end

#external_idObject (readonly)

Returns the value of attribute external_id.



27
28
29
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 27

def external_id
  @external_id
end

#idObject (readonly)

Returns the value of attribute id.



27
28
29
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 27

def id
  @id
end

#issuing_transaction_idObject (readonly)

Returns the value of attribute issuing_transaction_id.



27
28
29
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 27

def issuing_transaction_id
  @issuing_transaction_id
end

#tagsObject (readonly)

Returns the value of attribute tags.



27
28
29
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 27

def tags
  @tags
end

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



27
28
29
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 27

def transaction_id
  @transaction_id
end

#updatedObject (readonly)

Returns the value of attribute updated.



27
28
29
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 27

def updated
  @updated
end

Class Method Details

.create(withdrawal, user: nil) ⇒ Object

# Create an IssuingWithdrawal

Send a single IssuingWithdrawal object for creation in the Stark Infra API

## Parameters (required):

  • withdrawal [IssuingWithdrawal object]: IssuingWithdrawal object to be created in the API.

## Parameters (optional):

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call

## Return:

  • IssuingWithdrawal object with updated attributes



55
56
57
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 55

def self.create(withdrawal, user: nil)
  StarkInfra::Utils::Rest.post_single(entity: withdrawal, user: user, **resource)
end

.get(id, user: nil) ⇒ Object

# Retrieve a specific IssuingWithdrawal

Receive a single IssuingWithdrawal object previously created in the Stark Infra API by its id

## Parameters (required):

  • id [string]: object 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:

  • IssuingWithdrawal object with updated attributes



71
72
73
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 71

def self.get(id, user: nil)
  StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
end

.page(cursor: nil, limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil) ⇒ Object

# Retrieve paged IssuingWithdrawals

Receive a list of IssuingWithdrawals objects previously created in the Stark Infra API and the cursor to the next page.

## 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

  • external_ids [list of strings, default []]: external IDs. ex: [‘5656565656565656’, ‘4545454545454545’]

  • 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)

  • tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call

## Return:

  • list of IssuingWithdrawal objects with updated attributes

  • cursor to retrieve the next page of IssuingWithdrawal objects



119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 119

def self.page(cursor: nil, limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil)
  after = StarkInfra::Utils::Checks.check_date(after)
  before = StarkInfra::Utils::Checks.check_date(before)
  StarkInfra::Utils::Rest.get_page(
    cursor: cursor,
    limit: limit,
    external_ids: external_ids,
    after: after,
    before: before,
    tags: tags,
    user: user,
    **resource
  )
end

.query(limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil) ⇒ Object

# Retrieve IssuingWithdrawals

Receive a generator of IssuingWithdrawal 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

  • external_ids [list of strings, default []]: external IDs. ex: [‘5656565656565656’, ‘4545454545454545’]

  • 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)

  • tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call

## Return:

  • generator of IssuingWithdrawal objects with updated attributes



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 89

def self.query(limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil)
  after = StarkInfra::Utils::Checks.check_date(after)
  before = StarkInfra::Utils::Checks.check_date(before)
  StarkInfra::Utils::Rest.get_stream(
    limit: limit,
    external_ids: external_ids,
    after: after,
    before: before,
    tags: tags,
    user: user,
    **resource
  )
end

.resourceObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/issuingwithdrawal/issuingwithdrawal.rb', line 134

def self.resource
  {
    resource_name: 'IssuingWithdrawal',
    resource_maker: proc { |json|
      IssuingWithdrawal.new(
        amount: json['amount'],
        external_id: json['external_id'],
        description: json['description'],
        tags: json['tags'],
        id: json['id'],
        transaction_id: json['transaction_id'],
        issuing_transaction_id: json['issuing_transaction_id'],
        updated: json['updated'],
        created: json['created']
      )
    }
  }
end