From d8497aa0048d99efe32af60a3531522dcd250b1e Mon Sep 17 00:00:00 2001 From: Caio Dottori Date: Tue, 12 May 2020 23:18:46 -0300 Subject: [PATCH] Add boleto receiver_name and receiver_tax_id parameters --- lib/boleto/boleto.rb | 13 ++++++++++--- spec/boleto_spec.rb | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/boleto/boleto.rb b/lib/boleto/boleto.rb index 90c1197..89fe112 100644 --- a/lib/boleto/boleto.rb +++ b/lib/boleto/boleto.rb @@ -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 @@ -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 @@ -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 @@ -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'], diff --git a/spec/boleto_spec.rb b/spec/boleto_spec.rb index 0c3b0e8..000ae95 100644 --- a/spec/boleto_spec.rb +++ b/spec/boleto_spec.rb @@ -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: [