API integration library http://www.boletocloud.com
$ pip install boleto-cloud-python
or
$ python setup.py install
To access an API, first you have to create an account and generate a token at: app.boletocloud.com/api
With the token properly generated, pass the token as a string parameter in the instantiation of your object, as shown in the code below:
>>> from boletocloud import Ticket
>>> ticket = Ticket('your_token')
>>> ticket.create(self, bank, agency, number, wallet, recipient_name, recipient_cprf, recipient_address_zip, recipient_address_uf, recipient_address_locale, recipient_address_neighborhood, recipient_address_street, recipient_address_number, recipient_address_complement, emission, pay, document, ticket_number, title, value, payer_name, payer_cprf, payer_address_zip, payer_address_uf, payer_address_locale, payer_address_neighborhood, payer_address_street, payer_address_number, payer_address_complement, instruction)
A good option to inform the parameters in a simpler way is to create a dictionary with the data, this way:
params = {
'boleto.conta.banco': 237,
'boleto.conta.agencia': '1234-5',
'boleto.conta.numero': '123456-0',
'boleto.conta.carteira': 12,
'boleto.beneficiario.nome': 'DevAware Solutions',
'boleto.beneficiario.cprf': '15.719.277/0001-46',
'boleto.beneficiario.endereco.cep': '59020-000',
'boleto.beneficiario.endereco.uf': 'RN',
'boleto.beneficiario.endereco.localidade': 'Natal',
'boleto.beneficiario.endereco.bairro': 'Petrópolis',
'boleto.beneficiario.endereco.logradouro': 'Avenida Hermes da Fonseca',
'boleto.beneficiario.endereco.numero': 384,
'boleto.beneficiario.endereco.complemento': 'Sala 2A, segundo andar',
'boleto.emissao': '2014-07-11',
'boleto.vencimento': '2020-05-30',
'boleto.documento': 'EX1',
'boleto.numero': '12345678901-P',
'boleto.titulo': 'DM',
'boleto.valor': '1250.43',
'boleto.pagador.nome': 'Alberto Santos Dumont',
'boleto.pagador.cprf': '111.111.111-11',
'boleto.pagador.endereco.cep': '36240-000',
'boleto.pagador.endereco.uf': 'MG',
'boleto.pagador.endereco.localidade': 'Santos Dumont',
'boleto.pagador.endereco.bairro': 'Casa Natal',
'boleto.pagador.endereco.logradouro': 'BR-499',
'boleto.pagador.endereco.numero': 's/n',
'boleto.pagador.endereco.complemento': 'Sítio - Subindo a serra da Mantiqueira',
'boleto.instrucao': 'Atenção! NÃO RECEBER ESTE BOLETO.',
}
And pass the dictionary to create a method as shown in the example below:
>>> ticket.create(**params)
This method creates the ticket in the system and returns the ticket in PDF format with the inserted data from the parameters.
The Ticket class has the method search(). This method receives as a parameter the token that will allow you to access the ticket. Go to the administrative dashboard app.boletocloud.com/api and you will find the token in the information about the wanted. Then, pass the token as a parameter to the method and you will have the Download automatic file in PDF, as it is shown in the code below:
>>> ticket.search('token_ticket')
Lib also relies on aid methods that return important information that may be needed as well.
The lib has a property that returns the token entered in the creation of the object, see an example in the code below:
>>> ticket.token
>>> 'your_token'
If you need the API endpoint url, we have get_url() at your disposal, see an example below:
>>> ticket.get_url()
>>> 'https://sandbox.boletocloud.com/api/v1/boletos/'
Note that the [boletocloud.com] API (http://www.boletocloud.com) is still on BETA, as the company updates it, we will be implementing new features. For more information regarding the API, access: www.boletocloud.com/app/dev/api
Did you find a bug or have any suggestions for implementation? Feel free to send us a issue