leetchi-wallet-services 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/CONTRIBUTING.md +51 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +26 -0
  4. data/README.md +64 -0
  5. data/Rakefile +8 -0
  6. data/lib/leetchi-wallet-services.rb +21 -0
  7. data/lib/leetchi/beneficiary.rb +73 -0
  8. data/lib/leetchi/card.rb +42 -0
  9. data/lib/leetchi/contribution.rb +61 -0
  10. data/lib/leetchi/expense.rb +17 -0
  11. data/lib/leetchi/operation.rb +16 -0
  12. data/lib/leetchi/recurrent_contribution.rb +38 -0
  13. data/lib/leetchi/ressource.rb +75 -0
  14. data/lib/leetchi/strong_authentication.rb +15 -0
  15. data/lib/leetchi/transfer.rb +58 -0
  16. data/lib/leetchi/user.rb +148 -0
  17. data/lib/leetchi/wallet.rb +93 -0
  18. data/lib/leetchi/withdrawal.rb +41 -0
  19. data/spec/fixtures/leetchi_cassettes/beneficiary.yml +26926 -0
  20. data/spec/fixtures/leetchi_cassettes/card.yml +10524 -0
  21. data/spec/fixtures/leetchi_cassettes/contribution.yml +8175 -0
  22. data/spec/fixtures/leetchi_cassettes/expense-site.yml +45 -0
  23. data/spec/fixtures/leetchi_cassettes/expense.yml +126 -0
  24. data/spec/fixtures/leetchi_cassettes/operation.yml +126 -0
  25. data/spec/fixtures/leetchi_cassettes/recurrent_contribution.yml +564 -0
  26. data/spec/fixtures/leetchi_cassettes/strong_authentication.yml +208 -0
  27. data/spec/fixtures/leetchi_cassettes/transfer.yml +5679 -0
  28. data/spec/fixtures/leetchi_cassettes/user.yml +31848 -0
  29. data/spec/fixtures/leetchi_cassettes/wallet.yml +27719 -0
  30. data/spec/fixtures/leetchi_cassettes/withdrawal.yml +12001 -0
  31. data/spec/lib/leetchi/beneficiary_spec.rb +129 -0
  32. data/spec/lib/leetchi/card_spec.rb +50 -0
  33. data/spec/lib/leetchi/contribution_spec.rb +64 -0
  34. data/spec/lib/leetchi/expense_spec.rb +17 -0
  35. data/spec/lib/leetchi/operation_spec.rb +14 -0
  36. data/spec/lib/leetchi/recurrent_contribution_spec.rb +48 -0
  37. data/spec/lib/leetchi/ressource_spec.rb +7 -0
  38. data/spec/lib/leetchi/strong_authentication_spec.rb +17 -0
  39. data/spec/lib/leetchi/transfer_spec.rb +71 -0
  40. data/spec/lib/leetchi/user_spec.rb +130 -0
  41. data/spec/lib/leetchi/wallet_spec.rb +87 -0
  42. data/spec/lib/leetchi/withdrawal_spec.rb +89 -0
  43. data/spec/spec_helper.rb +19 -0
  44. metadata +119 -0
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,51 @@
1
+ # Contributing to Bankiwi
2
+
3
+ ## Bugs
4
+ A bug is a _demonstrable problem_ that is caused by the code in the repository. Good bug reports are extremely helpful - thank you!
5
+
6
+ Guidelines for bug reports:
7
+
8
+ 1. **Use the GitHub issue search**: check if the issue has already been reported.
9
+
10
+ 2. **Check if the issue has been fixed**: try to reproduce it using the latest `master` branch in the repository.
11
+
12
+ 3. **Isolate the problem**: ideally create a [reduced test case](http://css-tricks.com/6263-reduced-test-cases/) and a live example.
13
+
14
+ A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What browser(s) and OS experience the problem? What would you expect to be the outcome? All these details will help people to fix any potential bugs.
15
+
16
+ Example:
17
+
18
+ > Short and descriptive example bug report title
19
+ >
20
+ > A summary of the issue and the browser/OS environment in which it occurs.
21
+ > If suitable, include the steps required to reproduce the bug.
22
+ >
23
+ > 1. This is the first step
24
+ > 2. This is the second step
25
+ > 3. Further steps, etc.
26
+ >
27
+ > `<url>` (a link to the reduced test case)
28
+ >
29
+ > Screenshots of the bug. (especially if it's a visual one)
30
+ >
31
+ > Any other information you want to share that is relevant to the issue being reported. This might include the lines of code that you have identified as causing the bug, and potential solutions (and your opinions on their merits).
32
+ **[File a bug report](https://github.com/leetchi/bankiwi/issues/)**
33
+
34
+ ## Pull requests
35
+ Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits. If your contribution involves a significant amount of work or substantial changes to any part of the project, please open an issue to discuss it first.
36
+
37
+ Make sure to adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.). Please update any documentation that is relevant to the change you're making.
38
+
39
+ Please follow this process; it's the best way to get your work included in the project:
40
+
41
+ 1. Create a new branch based on master
42
+ 2. Once you've done your first commit on the newly created branch [Open a Pull Request](http://help.github.com/send-pull-requests/) with a clear title and description of the changes you intend to do
43
+ 3. Every pull request will be attributed a version number following this schema: [MAJOR_VERSION_NUMBER].[MINOR_VERSION_NUMBER].[PATCH_VERSION_NUMBER]
44
+ 4. Once your pull-request is fully tested, documented, and approved by everyone working on the project you will be ask to merge it with master.
45
+
46
+ You can then make your first push to production. Enjoy :-)
47
+
48
+ ## Do Not
49
+ Please **do not** use the issue tracker for personal support requests.
50
+
51
+ Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source :rubygems
2
+
3
+ gem "json"
4
+
5
+ group :test do
6
+ gem 'minitest'
7
+ gem 'webmock'
8
+ gem 'vcr'
9
+ gem 'turn'
10
+ gem 'rake'
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.2)
5
+ ansi (1.4.3)
6
+ crack (0.3.2)
7
+ json (1.7.6)
8
+ minitest (4.6.1)
9
+ rake (10.0.3)
10
+ turn (0.9.6)
11
+ ansi
12
+ vcr (2.4.0)
13
+ webmock (1.9.0)
14
+ addressable (>= 2.2.7)
15
+ crack (>= 0.1.7)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ json
22
+ minitest
23
+ rake
24
+ turn
25
+ vcr
26
+ webmock
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # leetchi-api-ruby-sdk
2
+
3
+ The gem for interacting with Leetchi API.
4
+ See the [API documentation](http://doc.api.leetchi.com/) for more details on the API.
5
+
6
+ Tested on the following versions of Ruby: 1.9.2, 1.9.3
7
+
8
+ ## Requirements
9
+
10
+ This gem uses mainly ruby stdlib and the *json* gem.
11
+
12
+ ## Configuration
13
+
14
+ Setup the following ENV:
15
+
16
+ ```ruby
17
+ ENV['LEETCHI_API_BASE_URL'] = "https://api-preprod.leetchi.com" # once you've run your test using the preproduction environment use the production one
18
+ ENV['LEETCHI_KEY_PATH'] = "abcd" # the full path to your leetchi key
19
+ ENV['LEETCHI_PASSPHRASE'] = "efgh" # you key's passphrase (leave blank if none)
20
+ ENV['LEETCHI_PARTNER_ID'] = "myID" # your Leetchi API ID
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ The gem implements the following resources:
26
+ - Beneficiary
27
+ - Card
28
+ - Contribution
29
+ - Expense
30
+ - Operation
31
+ - Recurrent Contribution (only available in preproduction)
32
+ - Strong Authentication
33
+ - Transfer
34
+ - User
35
+ - Wallet
36
+ - Withdrawal
37
+
38
+ Each resource has specifics methods such has `create`, `details`, `update`, etc. Those methods must be called with an ID and / or an Object matching the Leetchi API.
39
+ Calling those methods return the Leetchi API response has an object. Every executions are made synchronously.
40
+
41
+ ### Example
42
+
43
+ This example creates a user and returns its informations:
44
+
45
+ ```ruby
46
+ Leetchi::User.create({
47
+ 'Tag' => 'test',
48
+ 'Email' => 'my@email.com',
49
+ 'FistName' => 'Jack',
50
+ 'LastName' => 'Nelson',
51
+ 'CanRegisterMeanOfPayment' => true
52
+ })
53
+ ```
54
+
55
+ This example returns a specific user's data:
56
+
57
+ ```ruby
58
+ Leetchi::User.details(123)
59
+ ```
60
+
61
+ ### Tests
62
+ Make sure that you have run: ```bundle install```
63
+ Then you just have to run the rake task ```rake test``` to run all the test suite.
64
+ Feel free to report any test failure by creating an issue on the [Gem's Github](https://github.com/Leetchi/leetchi-api-ruby-sdk/issues)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.test_files = FileList['spec/lib/leetchi/*_spec.rb']
5
+ t.verbose = true
6
+ end
7
+
8
+ task :default => :test
@@ -0,0 +1,21 @@
1
+ module Leetchi
2
+
3
+ require 'json'
4
+ require 'base64'
5
+ require 'openssl'
6
+ require 'net/http'
7
+
8
+ require 'leetchi/ressource'
9
+ require 'leetchi/user'
10
+ require 'leetchi/wallet'
11
+ require 'leetchi/card'
12
+ require 'leetchi/contribution'
13
+ require 'leetchi/transfer'
14
+ require 'leetchi/beneficiary'
15
+ require 'leetchi/withdrawal'
16
+ require 'leetchi/strong_authentication'
17
+ require 'leetchi/operation'
18
+ require 'leetchi/expense'
19
+ require 'leetchi/recurrent_contribution'
20
+
21
+ end
@@ -0,0 +1,73 @@
1
+ module Leetchi
2
+ # A beneficiary is an item who is the target of withdrawal.
3
+ # It's the object that contains the bank details for a withdrawal.
4
+ # A beneficiary can be linked to a user.
5
+ class Beneficiary < Leetchi::Ressource
6
+
7
+ # Create a beneficiary
8
+ #
9
+ # * *Args* :
10
+ # - +data+ -> A JSON with the following attributes (Square brackets for optionals):
11
+ # * [Tag]
12
+ # * [UserID]
13
+ # * BankAccountOwnerName
14
+ # * BankAccountIBAN
15
+ # * BankAccountBIC
16
+ # * *Returns* :
17
+ # - A beneficiary object in case of success
18
+ #
19
+ def self.create(data)
20
+ post_request('beneficiaries', data)
21
+ end
22
+
23
+ # Get a beneficiary
24
+ #
25
+ # * *Args* :
26
+ # - +beneficiary_id+ -> The id of the beneficiary you want to get
27
+ # * *Returns* :
28
+ # - A beneficiary object if it exists
29
+ #
30
+ def self.details(beneficiary_id)
31
+ get_request(File.join('beneficiaries', beneficiary_id.to_s))
32
+ end
33
+
34
+ # Create a strong authentication for a given beneficiary
35
+ #
36
+ # * *Args* :
37
+ # - +beneficiary_id+ -> The id of the beneficiary you want strongly authenticate
38
+ # - +data+ -> A JSON with the following attributes (Square brackets for optionals):
39
+ # * [Tag]
40
+ # * *Returns* :
41
+ # - A strong authentication object
42
+ #
43
+ def self.create_strong_authentication(beneficiary_id, data)
44
+ post_request(File.join('beneficiaries', beneficiary_id.to_s, 'strongAuthentication'), data)
45
+ end
46
+
47
+ # Get the strong authentication for a given beneficiary
48
+ #
49
+ # * *Args* :
50
+ # - +beneficiary_id+ -> The id of the beneficiary you want strongly authenticate
51
+ # * *Returns* :
52
+ # - A strong authentication object
53
+ #
54
+ def self.get_strong_authentication(beneficiary_id)
55
+ get_request(File.join('beneficiaries', beneficiary_id.to_s, 'strongAuthentication'))
56
+ end
57
+
58
+ # Update a strong authentication object for a given beneficiary
59
+ #
60
+ # * *Args* :
61
+ # - +beneficiary_id+ -> The id of the beneficiary you want strongly authenticate
62
+ # - +data+ -> A JSON with the following attributes (Square brackets for optionals):
63
+ # * [Tag]
64
+ # * [IsDocumentsTransmitted]
65
+ # * *Returns* :
66
+ # - A strong authentication object
67
+ #
68
+ def self.update_strong_authentication(beneficiary_id, data)
69
+ put_request(File.join('beneficiaries', beneficiary_id.to_s, 'strongAuthentication'), data)
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,42 @@
1
+ module Leetchi
2
+ # A payment card.
3
+ class Card < Leetchi::Ressource
4
+
5
+ # Create a payment card
6
+ #
7
+ # * *Args* :
8
+ # - +data+ -> A JSON with the following attributes (Square brackets for optionals):
9
+ # * [Tag]
10
+ # * OwnerID
11
+ # * ReturnURL
12
+ # * [TemplateURL]
13
+ # * *Returns* :
14
+ # - A payment card object
15
+ #
16
+ def self.create(data)
17
+ post_request('cards', data)
18
+ end
19
+
20
+ # Get a payment card
21
+ #
22
+ # * *Args* :
23
+ # - +card_id+ -> The id of the card you want to retrieve
24
+ # * *Returns* :
25
+ # - A payment card object
26
+ #
27
+ def self.details(card_id)
28
+ get_request(File.join('cards', card_id.to_s))
29
+ end
30
+
31
+ # Delete a payment card
32
+ #
33
+ # * *Args* :
34
+ # - +card_id+ -> The id of the card you want to delete
35
+ # * *Returns* :
36
+ # - A "OK" string on success
37
+ #
38
+ def self.delete(card_id)
39
+ delete_request(File.join('cards', card_id.to_s))
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,61 @@
1
+ module Leetchi
2
+ # A contribution help you deposit money to a wallet.
3
+ class Contribution < Leetchi::Ressource
4
+
5
+ # Create a contribution
6
+ #
7
+ # * *Args* :
8
+ # - +data+ -> A JSON with the following attributes (Square brackets for optionals):
9
+ # * [Tag]
10
+ # * UserID
11
+ # * WalletID
12
+ # * Amount
13
+ # * [ClientFeeAmount]
14
+ # * ReturnURL
15
+ # * [TemplateURL]
16
+ # * [RegisterMeanOfPayment]
17
+ # * [PaymentCardID]
18
+ # * *Returns* :
19
+ # - A contribution object
20
+ #
21
+ def self.create(data)
22
+ post_request('contributions', data)
23
+ end
24
+
25
+ # Get a contribution
26
+ #
27
+ # * *Args* :
28
+ # - +contribution_id+ -> The id of the contribution you want to retrieve
29
+ # * *Returns* :
30
+ # - A contribution object
31
+ #
32
+ def self.details(contribution_id)
33
+ get_request(File.join('contributions', contribution_id.to_s))
34
+ end
35
+
36
+ # Refund a given contribution
37
+ #
38
+ # * *Args* :
39
+ # - +data+ -> A JSON with the following attributes (Square brackets for optionals):
40
+ # * [Tag]
41
+ # * ContributionID
42
+ # * UserID
43
+ # * *Returns* :
44
+ # - A refund object
45
+ #
46
+ def self.refund(data)
47
+ post_request(File.join('refunds'), data)
48
+ end
49
+
50
+ # Get a refund object
51
+ #
52
+ # * *Args* :
53
+ # - +contribution_refund_id+ -> The id of the refund you want to retrieve
54
+ # * *Returns* :
55
+ # - A refund object
56
+ #
57
+ def self.get_refund(contribution_refund_id)
58
+ get_request(File.join('refunds', contribution_refund_id.to_s))
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,17 @@
1
+ module Leetchi
2
+ # In order to make an expense you need to get a list of expense sites and then redirect a user to ExpenseURL.
3
+ # When the user selects a product and pays, you will be notified about an expense through the notification mechanism.
4
+ class Expense < Leetchi::Ressource
5
+
6
+ # Get an expense
7
+ #
8
+ # * *Args* :
9
+ # - +expense_id+ -> The id of the expense you want to retrieve
10
+ # * *Returns* :
11
+ # - An expense object
12
+ #
13
+ def self.get(expense_id)
14
+ get_request(File.join('expenses', expense_id.to_s))
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module Leetchi
2
+ # Operation
3
+ class Operation < Leetchi::Ressource
4
+
5
+ # Get an operation
6
+ #
7
+ # * *Args* :
8
+ # - +operation_id+ -> The id of the operation you want to retrieve
9
+ # * *Returns* :
10
+ # - An operation object
11
+ #
12
+ def self.get(operation_id)
13
+ get_request(File.join('operations', operation_id.to_s))
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,38 @@
1
+ module Leetchi
2
+
3
+ # Recurrent Contribution are available in test environment only, soon in production.
4
+ class RecurrentContribution < Leetchi::Ressource
5
+
6
+ # Create a recurrent contribution
7
+ #
8
+ # * *Args* :
9
+ # - +data+ -> A JSON with the following attributes (Square brackets for optionals):
10
+ # * [Tag]
11
+ # * UserID
12
+ # * WalletID
13
+ # * Amount
14
+ # * [ClientFeeAmount]
15
+ # * ReturnURL
16
+ # * [TemplateURL]
17
+ # * StartDate
18
+ # * FrequencyCode
19
+ # * NumberOfExecutions
20
+ # * *Returns* :
21
+ # - A recurrent contribution object
22
+ #
23
+ def self.create(data)
24
+ post_request('recurrent-contributions', data)
25
+ end
26
+
27
+ # Get a recurrent contribution
28
+ #
29
+ # * *Args* :
30
+ # - +recurrent_contributions_id+ -> The id of the recurrent contribution you want to retrieve
31
+ # * *Returns* :
32
+ # - A recurrent contribution object
33
+ #
34
+ def self.get(recurrent_contributions_id)
35
+ get_request(File.join('recurrent-contributions', recurrent_contributions_id.to_s))
36
+ end
37
+ end
38
+ end