Skip to content

Commit

Permalink
Merge pull request #46 from starkbank/feature/starkcore
Browse files Browse the repository at this point in the history
Use starkcore as dependency
  • Loading branch information
cdottori-stark authored Jan 6, 2023
2 parents 878e6fb + eee53ff commit ec1a10e
Show file tree
Hide file tree
Showing 58 changed files with 478 additions and 989 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Given a version number MAJOR.MINOR.PATCH, increment:


## [Unreleased]
### Changed
- internal structure to use starkcore as a dependency.

## [2.6.0] - 2021-09-04
### Added
Expand Down
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
starkbank (2.6.0)
starkbank-ecdsa (~> 0.0.5)
starkcore (~> 0.0.1)

GEM
remote: https://rubygems.org/
Expand All @@ -25,7 +25,8 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
ruby-progressbar (1.10.1)
starkbank-ecdsa (0.0.5)
starkcore (0.0.1)
starkbank-ecdsa (~> 2.0.0)
unicode-display_width (1.7.0)

PLATFORMS
Expand All @@ -38,4 +39,4 @@ DEPENDENCIES
starkbank!

BUNDLED WITH
2.1.4
2.4.1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1813,4 +1813,4 @@ If you have any questions about our SDK, just send us an email.
We will respond you quickly, pinky promise. We are here to help you integrate with us ASAP.
We also love feedback, so don't be shy about sharing your thoughts with us.

Email: developers@starkbank.com
Email: help@starkbank.com
8 changes: 4 additions & 4 deletions lib/balance/balance.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require_relative('../utils/resource')
require('starkcore')
require_relative('../utils/rest')
require_relative('../utils/checks')


module StarkBank
# # Balance object
Expand All @@ -17,13 +17,13 @@ module StarkBank
# - amount [integer, default nil]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
# - currency [string, default nil]: currency of the current workspace. Expect others to be added eventually. ex:'BRL'
# - updated [DateTime, default nil]: update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
class Balance < StarkBank::Utils::Resource
class Balance < StarkCore::Utils::Resource
attr_reader :amount, :currency, :updated
def initialize(amount:, currency:, updated:, id:)
super(id)
@amount = amount
@currency = currency
@updated = StarkBank::Utils::Checks.check_datetime(updated)
@updated = StarkCore::Utils::Checks.check_datetime(updated)
end

# # Retrieve the Balance object
Expand Down
18 changes: 9 additions & 9 deletions lib/boleto/boleto.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require_relative('../utils/resource')
require('starkcore')
require_relative('../utils/rest')
require_relative('../utils/checks')


module StarkBank
# # Boleto object
Expand Down Expand Up @@ -42,7 +42,7 @@ module StarkBank
# - status [string, default nil]: current Boleto status. ex: 'registered' or 'paid'
# - created [DateTime, default nil]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
# - our_number [string, default nil]: Reference number registered at the settlement bank. ex:'10131474'
class Boleto < StarkBank::Utils::Resource
class Boleto < StarkCore::Utils::Resource
attr_reader :amount, :name, :tax_id, :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :due, :fine, :interest, :overdue_limit, :receiver_name, :receiver_tax_id, :tags, :descriptions, :discounts, :id, :fee, :line, :bar_code, :status, :transaction_ids, :created, :our_number
def initialize(
amount:, name:, tax_id:, street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:,
Expand All @@ -60,7 +60,7 @@ def initialize(
@city = city
@state_code = state_code
@zip_code = zip_code
@due = StarkBank::Utils::Checks.check_date(due)
@due = StarkCore::Utils::Checks.check_date(due)
@fine = fine
@interest = interest
@overdue_limit = overdue_limit
Expand All @@ -74,7 +74,7 @@ def initialize(
@bar_code = bar_code
@status = status
@transaction_ids = transaction_ids
@created = StarkBank::Utils::Checks.check_datetime(created)
@created = StarkCore::Utils::Checks.check_datetime(created)
@our_number = our_number
end

Expand Down Expand Up @@ -144,8 +144,8 @@ def self.pdf(id, layout: nil, hidden_fields: nil, user: nil)
# ## Return:
# - generator of Boleto objects with updated attributes
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
StarkBank::Utils::Rest.get_stream(
limit: limit,
after: after,
Expand Down Expand Up @@ -176,8 +176,8 @@ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids:
# ## Return:
# - list of Boleto objects with updated attributes and cursor to retrieve the next page of Boleto objects
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
return StarkBank::Utils::Rest.get_page(
cursor: cursor,
limit: limit,
Expand Down
18 changes: 9 additions & 9 deletions lib/boleto/log.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative('../utils/resource')
require('starkcore')
require_relative('../utils/rest')
require_relative('../utils/checks')
require_relative('boleto')


module StarkBank
class Boleto
# # Boleto::Log object
Expand All @@ -20,14 +20,14 @@ class Boleto
# - errors [list of strings]: list of errors linked to this Boleto event
# - type [string]: type of the Boleto event which triggered the log creation. ex: 'registered' or 'paid'
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
class Log < StarkBank::Utils::Resource
class Log < StarkCore::Utils::Resource
attr_reader :id, :created, :type, :errors, :boleto
def initialize(id:, created:, type:, errors:, boleto:)
super(id)
@type = type
@errors = errors
@boleto = boleto
@created = StarkBank::Utils::Checks.check_datetime(created)
@created = StarkCore::Utils::Checks.check_datetime(created)
end

# # Retrieve a specific Log
Expand Down Expand Up @@ -61,8 +61,8 @@ def self.get(id, user: nil)
# ## Return:
# - list of Log objects with updated attributes
def self.query(limit: nil, after: nil, before: nil, types: nil, boleto_ids: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
StarkBank::Utils::Rest.get_stream(
limit: limit,
after: after,
Expand Down Expand Up @@ -91,8 +91,8 @@ def self.query(limit: nil, after: nil, before: nil, types: nil, boleto_ids: nil,
# ## Return:
# - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, boleto_ids: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
return StarkBank::Utils::Rest.get_page(
cursor: cursor,
limit: limit,
Expand All @@ -115,7 +115,7 @@ def self.resource
created: json['created'],
type: json['type'],
errors: json['errors'],
boleto: StarkBank::Utils::API.from_api_json(boleto_maker, json['boleto'])
boleto: StarkCore::Utils::API.from_api_json(boleto_maker, json['boleto'])
)
}
}
Expand Down
18 changes: 9 additions & 9 deletions lib/boleto_holmes/boleto_holmes.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require_relative('../utils/resource')
require('starkcore')
require_relative('../utils/rest')
require_relative('../utils/checks')


module StarkBank
# # BoletoHolmes object
Expand All @@ -23,7 +23,7 @@ module StarkBank
# - result [string, default nil]: result of boleto status investigation. ex: 'paid' or 'cancelled'
# - created [DateTime, default nil]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
# - updated [DateTime, default nil]: latest update datetime for the holmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
class BoletoHolmes < StarkBank::Utils::Resource
class BoletoHolmes < StarkCore::Utils::Resource
attr_reader :boleto_id, :tags, :id, :status, :result, :created, :updated
def initialize(
boleto_id:, tags: nil, id: nil, status: nil, result: nil, created: nil, updated: nil
Expand All @@ -33,8 +33,8 @@ def initialize(
@tags = tags
@status = status
@result = result
@created = StarkBank::Utils::Checks.check_datetime(created)
@updated = StarkBank::Utils::Checks.check_datetime(updated)
@created = StarkCore::Utils::Checks.check_datetime(created)
@updated = StarkCore::Utils::Checks.check_datetime(updated)
end

# # Create BoletoHolmes
Expand Down Expand Up @@ -86,8 +86,8 @@ def self.get(id, user: nil)
# ## Return:
# - generator of BoletoHolmes objects with updated attributes
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, boleto_id: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
StarkBank::Utils::Rest.get_stream(
limit: limit,
after: after,
Expand Down Expand Up @@ -120,8 +120,8 @@ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids:
# ## Return:
# - list of BoletoHolmes objects with updated attributes and cursor to retrieve the next page of BoletoHolmes objects
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, boleto_id: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
return StarkBank::Utils::Rest.get_page(
cursor: cursor,
limit: limit,
Expand Down
18 changes: 9 additions & 9 deletions lib/boleto_holmes/log.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative('../utils/resource')
require('starkcore')
require_relative('../utils/rest')
require_relative('../utils/checks')
require_relative('boleto_holmes')


module StarkBank
class BoletoHolmes
# # BoletoHolmes::Log object
Expand All @@ -19,13 +19,13 @@ class BoletoHolmes
# - holmes [BoletoHolmes]: BoletoHolmes entity to which the log refers to.
# - type [string]: type of the Boleto event which triggered the log creation. ex: 'registered' or 'paid'
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
class Log < StarkBank::Utils::Resource
class Log < StarkCore::Utils::Resource
attr_reader :id, :holmes, :type, :created
def initialize(id:, holmes:, type:, created:)
super(id)
@holmes = holmes
@type = type
@created = StarkBank::Utils::Checks.check_datetime(created)
@created = StarkCore::Utils::Checks.check_datetime(created)
end

# # Retrieve a specific Log
Expand Down Expand Up @@ -59,8 +59,8 @@ def self.get(id, user: nil)
# ## Return:
# - list of Log objects with updated attributes
def self.query(limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
StarkBank::Utils::Rest.get_stream(
limit: limit,
after: after,
Expand Down Expand Up @@ -89,8 +89,8 @@ def self.query(limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil,
# ## Return:
# - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
return StarkBank::Utils::Rest.get_page(
cursor: cursor,
limit: limit,
Expand All @@ -110,7 +110,7 @@ def self.resource
resource_maker: proc { |json|
Log.new(
id: json['id'],
holmes: StarkBank::Utils::API.from_api_json(holmes_maker, json['holmes']),
holmes: StarkCore::Utils::API.from_api_json(holmes_maker, json['holmes']),
type: json['type'],
created: json['created']
)
Expand Down
18 changes: 9 additions & 9 deletions lib/boleto_payment/boleto_payment.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require_relative('../utils/resource')
require('starkcore')
require_relative('../utils/rest')
require_relative('../utils/checks')


module StarkBank
# # BoletoPayment object
Expand All @@ -29,20 +29,20 @@ module StarkBank
# - amount [int, default nil]: amount automatically calculated from line or bar_code. ex: 23456 (= R$ 234.56)
# - fee [integer, default nil]: fee charged when the boleto payment is created. ex: 200 (= R$ 2.00)
# - created [DateTime, default nil]: creation datetime for the payment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
class BoletoPayment < StarkBank::Utils::Resource
class BoletoPayment < StarkCore::Utils::Resource
attr_reader :tax_id, :description, :line, :bar_code, :scheduled, :tags, :id, :status, :amount, :fee, :created
def initialize(tax_id:, description:, line: nil, bar_code: nil, scheduled: nil, tags: nil, id: nil, status: nil, amount: nil, fee: nil, created: nil)
super(id)
@tax_id = tax_id
@description = description
@line = line
@bar_code = bar_code
@scheduled = StarkBank::Utils::Checks.check_date(scheduled)
@scheduled = StarkCore::Utils::Checks.check_date(scheduled)
@tags = tags
@status = status
@amount = amount
@fee = fee
@created = StarkBank::Utils::Checks.check_datetime(created)
@created = StarkCore::Utils::Checks.check_datetime(created)
end

# # Create BoletoPayments
Expand Down Expand Up @@ -110,8 +110,8 @@ def self.pdf(id, user: nil)
# ## Return:
# - generator of BoletoPayment objects with updated attributes
def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
StarkBank::Utils::Rest.get_stream(
user: user,
limit: limit,
Expand Down Expand Up @@ -142,8 +142,8 @@ def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status:
# ## Return:
# - list of BoletoPayment objects with updated attributes and cursor to retrieve the next page of BoletoPayment objects
def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
after = StarkBank::Utils::Checks.check_date(after)
before = StarkBank::Utils::Checks.check_date(before)
after = StarkCore::Utils::Checks.check_date(after)
before = StarkCore::Utils::Checks.check_date(before)
return StarkBank::Utils::Rest.get_page(
cursor: cursor,
user: user,
Expand Down
Loading

0 comments on commit ec1a10e

Please sign in to comment.