Dibuk
TODO: describe your gem
todo
Installation
Add this line to your application's Gemfile:
gem 'dibuk'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install dibuk
Terms
- Seller - Dibuk`s client, eshop, reseller, ..
- User - end customer, Seller`s customer
- Order - order which User made in eshop
Usage
1. Create a client
client = Dibuk::Client.new(seller_id: 'string', signature: 'string', sandbox: true)
2. Set an User
user = Dibuk::User.new(
id: '123',
email: 'john.doe@example.com',
name: 'John',
surname: 'Doe'
)
3. Set an Item
item = Dibuk::Item.new(
id: '15351',
order_id: '12345641',
payment_id: 'int',
price: '12.5',
currency: 'EUR',
unique_id: '13512151'
)
4. Create a license (buy)
This function will create license. It need to be called just once of each item and user. Repeated call with same date will not create new license and still return success.
response = client.license(user, item)
response.success?
5a. Send an ebook to email
This function use Dibuk`s server to send ebook by email.
We support @kindle.com and @pocket email addresses.
response = client.send(user, item, 'kindle.email@example.com')
response.success?
5b. Get a download links
Returns links to direct download of current users`s files. It is limited in time urls related to current user (eg. ebook contains user`s info). You can use it to download from server or directly redirect user to them.
response = client.links(user, item)
response.success?
response.all
response.epub
Errors
response.error_code
response.limit_exceeded?
response.not_buyed?
Example
client = Dibuk::Client.new(seller_id: 'string', signature: 'string', sandbox: true)
user = Dibuk::User.new(
id: '123',
email: 'john.doe@example.com',
name: 'John',
surname: 'Doe'
)
item = Dibuk::Item.new(
id: '15351',
order_id: '12345641',
payment_id: 'int',
price: '12.5',
currency: 'EUR',
unique_id: '13512151'
)
licensed = client.license(user, item)
sent = client.send(user, item, 'kindle.email@example.com')
links = client.links(user, item)
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/dibukeu/client-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Dibuk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.