Skip to content

Commit

Permalink
Add boleto receiver_name and receiver_tax_id parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
cdottori-stark committed May 13, 2020
1 parent 08c3dfb commit d8497aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/boleto/boleto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module StarkBank
# - fine [float, default 0.0]: Boleto fine for overdue payment in %. ex: 2.5
# - interest [float, default 0.0]: Boleto monthly interest for overdue payment in %. ex: 5.2
# - overdue_limit [integer, default 59]: limit in days for payment after due date. ex: 7 (max: 59)
# - receiver_name [string]: receiver (Sacador Avalista) full name. ex: 'Anthony Edward Stark'
# - receiver_tax_id [string]: receiver (Sacador Avalista) tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
# - descriptions [list of dictionaries, default nil]: list of dictionaries with 'text':string and (optional) 'amount':int pairs
# - discounts [list of dictionaries, default nil]: list of dictionaries with 'percentage':float and 'date':Date or string pairs
# - tags [list of strings]: list of strings for tagging
Expand All @@ -39,11 +41,12 @@ 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)
class Boleto < StarkBank::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, :tags, :descriptions, :discounts, :id, :fee, :line, :bar_code, :status, :created
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, :created
def initialize(
amount:, name:, tax_id:, street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:,
due: nil, fine: nil, interest: nil, overdue_limit: nil, tags: nil, descriptions: nil, discounts: nil,
id: nil, fee: nil, line: nil, bar_code: nil, status: nil, created: nil
due: nil, fine: nil, interest: nil, overdue_limit: nil, receiver_name: nil, receiver_tax_id: nil,
tags: nil, descriptions: nil, discounts: nil, id: nil, fee: nil, line: nil, bar_code: nil,
status: nil, created: nil
)
super(id)
@amount = amount
Expand All @@ -59,6 +62,8 @@ def initialize(
@fine = fine
@interest = interest
@overdue_limit = overdue_limit
@receiver_name = receiver_name
@receiver_tax_id = receiver_tax_id
@tags = tags
@descriptions = descriptions
@discounts = discounts
Expand Down Expand Up @@ -181,6 +186,8 @@ def self.resource
fine: json['fine'],
interest: json['interest'],
overdue_limit: json['overdue_limit'],
receiver_name: json['receiver_name'],
receiver_tax_id: json['receiver_tax_id'],
tags: json['tags'],
descriptions: json['descriptions'],
discounts: json['discounts'],
Expand Down
2 changes: 2 additions & 0 deletions spec/boleto_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def example
zip_code: '01234-567',
tax_id: '012.345.678-90',
overdue_limit: 10,
receiver_name: 'Random Receiver',
receiver_tax_id: '123.456.789-09',
fine: 0.00,
interest: 0.00,
descriptions: [
Expand Down

0 comments on commit d8497aa

Please sign in to comment.