mangopay 3.0.25 → 3.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +30 -28
  3. data/.rspec +2 -2
  4. data/.travis.yml +13 -4
  5. data/Gemfile +2 -2
  6. data/LICENSE +20 -20
  7. data/README.md +126 -126
  8. data/bin/mangopay +9 -9
  9. data/lib/generators/mangopay/install_generator.rb +60 -60
  10. data/lib/generators/templates/mangopay.rb.erb +5 -5
  11. data/lib/mangopay.rb +228 -225
  12. data/lib/mangopay/authorization_token.rb +88 -88
  13. data/lib/mangopay/bank_account.rb +38 -38
  14. data/lib/mangopay/bankingaliases.rb +29 -0
  15. data/lib/mangopay/bankingaliases_iban.rb +16 -0
  16. data/lib/mangopay/card.rb +8 -8
  17. data/lib/mangopay/card_registration.rb +9 -9
  18. data/lib/mangopay/client.rb +74 -74
  19. data/lib/mangopay/dispute.rb +130 -130
  20. data/lib/mangopay/errors.rb +61 -61
  21. data/lib/mangopay/event.rb +18 -18
  22. data/lib/mangopay/filter_parameters.rb +46 -46
  23. data/lib/mangopay/hook.rb +9 -9
  24. data/lib/mangopay/http_calls.rb +85 -85
  25. data/lib/mangopay/json.rb +14 -14
  26. data/lib/mangopay/kyc_document.rb +70 -70
  27. data/lib/mangopay/legal_user.rb +15 -15
  28. data/lib/mangopay/mandate.rb +32 -32
  29. data/lib/mangopay/natural_user.rb +14 -14
  30. data/lib/mangopay/pay_in.rb +96 -85
  31. data/lib/mangopay/pay_out.rb +14 -14
  32. data/lib/mangopay/pre_authorization.rb +13 -13
  33. data/lib/mangopay/refund.rb +7 -7
  34. data/lib/mangopay/report.rb +17 -17
  35. data/lib/mangopay/resource.rb +21 -21
  36. data/lib/mangopay/transaction.rb +24 -24
  37. data/lib/mangopay/transfer.rb +9 -9
  38. data/lib/mangopay/user.rb +43 -43
  39. data/lib/mangopay/version.rb +3 -3
  40. data/lib/mangopay/wallet.rb +17 -17
  41. data/mangopay.gemspec +30 -30
  42. data/spec/mangopay/authorization_token_spec.rb +70 -70
  43. data/spec/mangopay/bank_account_spec.rb +97 -97
  44. data/spec/mangopay/bankingaliases_spec.rb +29 -0
  45. data/spec/mangopay/card_registration_spec.rb +73 -73
  46. data/spec/mangopay/client_spec.rb +110 -110
  47. data/spec/mangopay/configuration_spec.rb +95 -95
  48. data/spec/mangopay/dispute_spec.rb +262 -262
  49. data/spec/mangopay/event_spec.rb +31 -31
  50. data/spec/mangopay/fetch_filters_spec.rb +63 -63
  51. data/spec/mangopay/hook_spec.rb +37 -37
  52. data/spec/mangopay/idempotency_spec.rb +41 -41
  53. data/spec/mangopay/kyc_document_spec.rb +103 -103
  54. data/spec/mangopay/log_requests_filter_spec.rb +25 -25
  55. data/spec/mangopay/mandate_spec.rb +92 -92
  56. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
  57. data/spec/mangopay/payin_card_direct_spec.rb +68 -68
  58. data/spec/mangopay/payin_card_web_spec.rb +47 -38
  59. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
  60. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
  61. data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
  62. data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
  63. data/spec/mangopay/payout_bankwire_spec.rb +54 -54
  64. data/spec/mangopay/preauthorization_spec.rb +42 -42
  65. data/spec/mangopay/refund_spec.rb +21 -21
  66. data/spec/mangopay/report_spec.rb +39 -39
  67. data/spec/mangopay/shared_resources.rb +397 -381
  68. data/spec/mangopay/transaction_spec.rb +54 -54
  69. data/spec/mangopay/transfer_spec.rb +69 -69
  70. data/spec/mangopay/user_spec.rb +137 -137
  71. data/spec/mangopay/wallet_spec.rb +80 -80
  72. data/spec/spec_helper.rb +31 -31
  73. metadata +7 -6
  74. data/lib/mangopay/temp.rb +0 -74
  75. data/spec/mangopay/temp_paymentcard_spec.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3744a337ed590051d5750cb20eb6d30746c6fb62
4
- data.tar.gz: 0d1a97b49c9421f63ecfedac2c643d9ff3ed18a0
3
+ metadata.gz: 8c19ff2ef0f7aa01b41358106dd62a827816285b
4
+ data.tar.gz: 4d5324d03c874f70950a7eeb1ee643bddf2367c7
5
5
  SHA512:
6
- metadata.gz: 0e1f921d2827f3fe78cefa3fa00e445d108e3872576a49e3a3cc0da7fc9c0a2ab5c3c1a0d781d34997be24f98c764a6a9ce527e188da0e39cc6ae3f36c2949c5
7
- data.tar.gz: a933d8036dd47d51a1b19faa486f84742b49190ffde645b8fb6282ca665d65bf6bca9bbae947bfbabe39ba90681cdb17cb5cc61c7cdbabdb03945a11a1e62458
6
+ metadata.gz: e49f9d0f623fc9bbd564182b65d41eff6d39e9a1f0beaf6cfe47263892ca241d2655ce78b633245e9fc4f70209e1f8e387a8101a22f2632e1d4a94ed6b50100d
7
+ data.tar.gz: 7e3edc86ee6bb3eaa7a3d6462b3e836e23ce000b6b80183da025fa31f7724b0186f82b99a5ffcc1ddfdcc190cfca8aa9a60f1bfc7b4094be0cbe72174f5fe4b1
data/.gitignore CHANGED
@@ -1,28 +1,30 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- coverage
6
- InstalledFiles
7
- lib/bundler/man
8
- pkg
9
- rdoc
10
- spec/reports
11
- spec/tmp/*.tmp
12
- test/tmp
13
- test/version_tmp
14
- tags
15
-
16
- # YARD artifacts
17
- .yardoc
18
- _yardoc
19
- doc/
20
-
21
- .DS_Store
22
- .rvmrc
23
- /Gemfile.lock
24
- /mangopay-*.gem
25
-
26
- /nbproject/
27
-
28
- /*.sublime-*
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ spec/tmp/*.tmp
12
+ test/tmp
13
+ test/version_tmp
14
+ tags
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
20
+
21
+ .DS_Store
22
+ .rvmrc
23
+ /Gemfile.lock
24
+ /mangopay-*.gem
25
+
26
+ /nbproject/
27
+
28
+ /*.sublime-*
29
+
30
+ .idea
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --color
2
- --profile
1
+ --color
2
+ --profile
3
3
  --r spec_helper
data/.travis.yml CHANGED
@@ -1,4 +1,13 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- script: bundle exec rspec
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rspec
5
+ deploy:
6
+ provider: rubygems
7
+ api_key:
8
+ secure: gvlnYEh9cyL+mYeudKzlD+2Po+LgIzCjHzggJH+WDcbtgxlGAFpxbVJOOm/KY8VKhMgIudNV7FJl4Gl4rrG8JjNxbb+qM57ypU3yyDcUesQ+uj0DnN+xszv7M+XtcRQMlhkStawoj/E0QMYBPkAAr1lBpPIFQdC17GDkdn5XvaQ=
9
+ gem: mangopay
10
+ on:
11
+ tags: false
12
+ repo: Mangopay/mangopay2-ruby-sdk
13
+ branch: release
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source "https://rubygems.org"
2
- gemspec
1
+ source "https://rubygems.org"
2
+ gemspec
data/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2013 Mangopay
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Mangopay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,126 +1,126 @@
1
- # Mangopay Ruby SDK [![Build Status](https://travis-ci.org/Mangopay/mangopay2-ruby-sdk.svg?branch=master)](https://travis-ci.org/Mangopay/mangopay2-ruby-sdk)
2
-
3
- The gem for interacting with the version 2 of the Mangopay API.
4
- See the [API documentation](http://docs.mangopay.com/api-references/)
5
- for more details on the API.
6
-
7
- Tested on the following versions of Ruby: 1.9.2, 1.9.3, 2.0.0
8
-
9
- ## NEWS
10
-
11
- ### Version 3.*
12
- **BREAKING CHANGES:** This version (3.\*) of the gem is targeting the Mangopay API Version 2. It has a brand new structure to make the api calls easier to use and is not backward compatible with 2.\* series.
13
-
14
- Since [v3.0.17](https://github.com/Mangopay/mangopay2-ruby-sdk/releases/tag/v3.0.17) of the SDK, you must be using at least v2.01 of the API (more information about the changes required [here](https://docs.mangopay.com/api-v2-01-overview/))
15
-
16
- Account creation
17
- -------------------------------------------------
18
- You can get yourself a [free sandbox account](https://www.mangopay.com/signup/create-sandbox/) or sign up for a [production account](https://www.mangopay.com/signup/submit-your-app/go-live/) (note that validation of your production account can take a few days, so think about doing it in advance of when you actually want to go live).
19
-
20
- ## Usage
21
-
22
- ### Install
23
- * You can get yourself a [free sandbox account](https://www.mangopay.com/get-started/create-sandbox/) or sign up for a [production account](https://www.mangopay.com/get-started/submit-your-app/create-credentials/) (note that validation of your production account can take a few days, so think about doing it in advance of when you actually want to go live).
24
-
25
- * Install the gem by either running ```gem install mangopay```
26
- or by adding it to your Gemfile ```gem 'mangopay'```
27
-
28
- * Using the credential info from the signup process above, call ```MangoPay.configure``` in your script as shown in the snippet below.
29
-
30
- ### Examples
31
-
32
- ```ruby
33
- require 'mangopay'
34
-
35
-
36
- # configuration
37
- MangoPay.configure do |c|
38
- c.preproduction = true
39
- c.client_id = 'YOUR_CLIENT_ID'
40
- c.client_passphrase = 'YOUR_CLIENT_PASSWORD'
41
- c.log_file = File.join('mypath', 'mangopay.log')
42
- end
43
-
44
-
45
- # get some user by id
46
- john = MangoPay::User.fetch(john_id) # => {FirstName"=>"John", "LastName"=>"Doe", ...}
47
-
48
-
49
- # update some of his data
50
- MangoPay::NaturalUser.update(john_id, {'LastName' => 'CHANGED'}) # => {FirstName"=>"John", "LastName"=>"CHANGED", ...}
51
-
52
-
53
- # get all users (with pagination)
54
- pagination = {'page' => 1, 'per_page' => 8} # get 1st page, 8 items per page
55
- users = MangoPay::User.fetch(pagination) # => [{...}, ...]: list of 8 users data hashes
56
- pagination # => {"page"=>1, "per_page"=>8, "total_pages"=>748, "total_items"=>5978}
57
-
58
-
59
- # get John's bank accounts
60
- accounts = MangoPay::BankAccount.fetch(john_id) # => [{...}, ...]: list of accounts data hashes (10 per page by default)
61
-
62
-
63
- # error handling
64
- begin
65
- MangoPay::NaturalUser.create({})
66
- rescue MangoPay::ResponseError => ex
67
-
68
- ex # => #<MangoPay::ResponseError: One or several required parameters are missing or incorrect. [...] FirstName: The FirstName field is required. LastName: The LastName field is required. Nationality: The Nationality field is required.>
69
-
70
- ex.details # => {
71
- # "Message"=>"One or several required parameters are missing or incorrect. [...]",
72
- # "Type"=>"param_error",
73
- # "Id"=>"5c080105-4da3-467d-820d-0906164e55fe",
74
- # "Date"=>1409048671.0,
75
- # "errors"=>{
76
- # "FirstName"=>"The FirstName field is required.",
77
- # "LastName"=>"The LastName field is required.", ...},
78
- # "Code"=>"400",
79
- # "Url"=>"/v2/.../users/natural"
80
- # }
81
- end
82
- ```
83
-
84
- ### Log requests and responses
85
- You can easily enable logs by setting the ```log_file``` configuration option (see the section **configuration** above). If you don't want logs, remove the ```log_file``` line.
86
-
87
- Requests and responses are filtered, so confidential data is not saved in logs.
88
-
89
- ### Tests
90
- Make sure that you have run: ```bundle install```
91
- Then you just have to run rspec ```rspec``` to run all the test suite.
92
- Feel free to report any test failure by creating an issue
93
- on the [Gem's Github](https://github.com/Mangopay/mangopay2-ruby-sdk/issues)
94
-
95
- ## Contributing
96
-
97
- 1. Fork the repo.
98
-
99
- 2. Run the tests. We only take pull requests with passing tests, and it's great
100
- to know that you have a clean slate: `bundle && bundle exec rspec`
101
-
102
- 3. Add a test for your change. Only refactoring and documentation changes
103
- require no new tests. If you are adding functionality or fixing a bug, we need
104
- a test!
105
-
106
- 4. Make the test pass.
107
-
108
- 5. Push to your fork and submit a pull request.
109
-
110
- At this point you're waiting on us. We like to at least comment on, if not
111
- accept, pull requests within three business days (and, typically, one business
112
- day). We may suggest some changes or improvements or alternatives.
113
-
114
- Syntax:
115
-
116
- * Two spaces, no tabs.
117
- * No trailing whitespace. Blank lines should not have any space.
118
- * Prefer &&/|| over and/or.
119
- * MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
120
- * a = b and not a=b.
121
- * Follow the conventions you see used in the source already.
122
-
123
- A contribution can also be as simple as a +1 on issues tickets to show us
124
- what you would like to see in this gem.
125
-
126
- That's it for now. Good Hacking...
1
+ # Mangopay Ruby SDK [![Build Status](https://travis-ci.org/Mangopay/mangopay2-ruby-sdk.svg?branch=master)](https://travis-ci.org/Mangopay/mangopay2-ruby-sdk)
2
+
3
+ The gem for interacting with the version 2 of the Mangopay API.
4
+ See the [API documentation](http://docs.mangopay.com/api-references/)
5
+ for more details on the API.
6
+
7
+ Tested on the following versions of Ruby: 1.9.2, 1.9.3, 2.0.0
8
+
9
+ ## NEWS
10
+
11
+ ### Version 3.*
12
+ **BREAKING CHANGES:** This version (3.\*) of the gem is targeting the Mangopay API Version 2. It has a brand new structure to make the api calls easier to use and is not backward compatible with 2.\* series.
13
+
14
+ Since [v3.0.17](https://github.com/Mangopay/mangopay2-ruby-sdk/releases/tag/v3.0.17) of the SDK, you must be using at least v2.01 of the API (more information about the changes required [here](https://docs.mangopay.com/api-v2-01-overview/))
15
+
16
+ Account creation
17
+ -------------------------------------------------
18
+ You can get yourself a [free sandbox account](https://www.mangopay.com/signup/create-sandbox/) or sign up for a [production account](https://www.mangopay.com/signup/production-account/) (note that validation of your production account can take a few days, so think about doing it in advance of when you actually want to go live).
19
+
20
+ ## Usage
21
+
22
+ ### Install
23
+ * You can get yourself a [free sandbox account](https://www.mangopay.com/get-started/create-sandbox/) or sign up for a [production account](https://www.mangopay.com/signup/production-account/) (note that validation of your production account can take a few days, so think about doing it in advance of when you actually want to go live).
24
+
25
+ * Install the gem by either running ```gem install mangopay```
26
+ or by adding it to your Gemfile ```gem 'mangopay'```
27
+
28
+ * Using the credential info from the signup process above, call ```MangoPay.configure``` in your script as shown in the snippet below.
29
+
30
+ ### Examples
31
+
32
+ ```ruby
33
+ require 'mangopay'
34
+
35
+
36
+ # configuration
37
+ MangoPay.configure do |c|
38
+ c.preproduction = true
39
+ c.client_id = 'YOUR_CLIENT_ID'
40
+ c.client_passphrase = 'YOUR_CLIENT_PASSWORD'
41
+ c.log_file = File.join('mypath', 'mangopay.log')
42
+ end
43
+
44
+
45
+ # get some user by id
46
+ john = MangoPay::User.fetch(john_id) # => {FirstName"=>"John", "LastName"=>"Doe", ...}
47
+
48
+
49
+ # update some of his data
50
+ MangoPay::NaturalUser.update(john_id, {'LastName' => 'CHANGED'}) # => {FirstName"=>"John", "LastName"=>"CHANGED", ...}
51
+
52
+
53
+ # get all users (with pagination)
54
+ pagination = {'page' => 1, 'per_page' => 8} # get 1st page, 8 items per page
55
+ users = MangoPay::User.fetch(pagination) # => [{...}, ...]: list of 8 users data hashes
56
+ pagination # => {"page"=>1, "per_page"=>8, "total_pages"=>748, "total_items"=>5978}
57
+
58
+
59
+ # get John's bank accounts
60
+ accounts = MangoPay::BankAccount.fetch(john_id) # => [{...}, ...]: list of accounts data hashes (10 per page by default)
61
+
62
+
63
+ # error handling
64
+ begin
65
+ MangoPay::NaturalUser.create({})
66
+ rescue MangoPay::ResponseError => ex
67
+
68
+ ex # => #<MangoPay::ResponseError: One or several required parameters are missing or incorrect. [...] FirstName: The FirstName field is required. LastName: The LastName field is required. Nationality: The Nationality field is required.>
69
+
70
+ ex.details # => {
71
+ # "Message"=>"One or several required parameters are missing or incorrect. [...]",
72
+ # "Type"=>"param_error",
73
+ # "Id"=>"5c080105-4da3-467d-820d-0906164e55fe",
74
+ # "Date"=>1409048671.0,
75
+ # "errors"=>{
76
+ # "FirstName"=>"The FirstName field is required.",
77
+ # "LastName"=>"The LastName field is required.", ...},
78
+ # "Code"=>"400",
79
+ # "Url"=>"/v2/.../users/natural"
80
+ # }
81
+ end
82
+ ```
83
+
84
+ ### Log requests and responses
85
+ You can easily enable logs by setting the ```log_file``` configuration option (see the section **configuration** above). If you don't want logs, remove the ```log_file``` line.
86
+
87
+ Requests and responses are filtered, so confidential data is not saved in logs.
88
+
89
+ ### Tests
90
+ Make sure that you have run: ```bundle install```
91
+ Then you just have to run rspec ```rspec``` to run all the test suite.
92
+ Feel free to report any test failure by creating an issue
93
+ on the [Gem's Github](https://github.com/Mangopay/mangopay2-ruby-sdk/issues)
94
+
95
+ ## Contributing
96
+
97
+ 1. Fork the repo.
98
+
99
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
100
+ to know that you have a clean slate: `bundle && bundle exec rspec`
101
+
102
+ 3. Add a test for your change. Only refactoring and documentation changes
103
+ require no new tests. If you are adding functionality or fixing a bug, we need
104
+ a test!
105
+
106
+ 4. Make the test pass.
107
+
108
+ 5. Push to your fork and submit a pull request.
109
+
110
+ At this point you're waiting on us. We like to at least comment on, if not
111
+ accept, pull requests within three business days (and, typically, one business
112
+ day). We may suggest some changes or improvements or alternatives.
113
+
114
+ Syntax:
115
+
116
+ * Two spaces, no tabs.
117
+ * No trailing whitespace. Blank lines should not have any space.
118
+ * Prefer &&/|| over and/or.
119
+ * MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
120
+ * a = b and not a=b.
121
+ * Follow the conventions you see used in the source already.
122
+
123
+ A contribution can also be as simple as a +1 on issues tickets to show us
124
+ what you would like to see in this gem.
125
+
126
+ That's it for now. Good Hacking...
data/bin/mangopay CHANGED
@@ -1,9 +1,9 @@
1
- #!/usr/bin/env ruby
2
-
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- libs << " -r #{File.dirname(__FILE__) + '/../lib/mangopay'}"
7
-
8
- puts "Loading MangoPay gem"
9
- exec "#{irb} #{libs}"
1
+ #!/usr/bin/env ruby
2
+
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/mangopay'}"
7
+
8
+ puts "Loading MangoPay gem"
9
+ exec "#{irb} #{libs}"
@@ -1,60 +1,60 @@
1
- require 'rails/generators/base'
2
- require 'mangopay'
3
-
4
- module Mangopay
5
- module Generators
6
- class InstallGenerator < Rails::Generators::Base
7
- source_root File.expand_path('../../templates', __FILE__)
8
- argument :client_id, type: :string,
9
- desc: 'The id you want to use to query the MangoPay API (must match with the regex ^[a-z0-9_-]{4,20}$)'
10
- argument :client_name, type: :string, desc: "Full name of you're organization"
11
- argument :client_email, type: :string, desc: "An email for future contacts"
12
- class_option :preproduction, type: :boolean, default: true, desc: 'Whether or not use the preproduction environment'
13
-
14
- desc 'Installs all the basic configuration of the mangopay gem'
15
- def setup
16
- begin
17
- client = client_id_valid?
18
- remove_file 'config/initializers/mangopay.rb'
19
- @client_id = client_id
20
- @client_passphrase = client['Passphrase']
21
- template 'mangopay.rb.erb', 'config/initializers/mangopay.rb'
22
- rescue => e
23
- puts e.message
24
- end
25
- end
26
-
27
- protected
28
-
29
- def client_id_valid?
30
- check_client_id_validity
31
- check_client_id_availablility
32
- end
33
-
34
- def check_client_id_validity
35
- if (/^[a-z0-9_-]{4,20}$/ =~ client_id).nil?
36
- raise "The client_id must match the regexp ^[a-z0-9_-]{4,20}$"
37
- end
38
- end
39
-
40
- def check_client_id_availablility
41
- client = create_client
42
- if client['Type'] == 'ClientID_already_exist'
43
- raise client['Message']
44
- end
45
- client
46
- end
47
-
48
- def create_client
49
- MangoPay.configure do |c|
50
- c.preproduction = options[:preproduction]
51
- end
52
- MangoPay::Client.create({
53
- ClientID: client_id,
54
- Name: client_name,
55
- Email: client_email
56
- })
57
- end
58
- end
59
- end
60
- end
1
+ require 'rails/generators/base'
2
+ require 'mangopay'
3
+
4
+ module Mangopay
5
+ module Generators
6
+ class InstallGenerator < Rails::Generators::Base
7
+ source_root File.expand_path('../../templates', __FILE__)
8
+ argument :client_id, type: :string,
9
+ desc: 'The id you want to use to query the MangoPay API (must match with the regex ^[a-z0-9_-]{4,20}$)'
10
+ argument :client_name, type: :string, desc: "Full name of you're organization"
11
+ argument :client_email, type: :string, desc: "An email for future contacts"
12
+ class_option :preproduction, type: :boolean, default: true, desc: 'Whether or not use the preproduction environment'
13
+
14
+ desc 'Installs all the basic configuration of the mangopay gem'
15
+ def setup
16
+ begin
17
+ client = client_id_valid?
18
+ remove_file 'config/initializers/mangopay.rb'
19
+ @client_id = client_id
20
+ @client_passphrase = client['Passphrase']
21
+ template 'mangopay.rb.erb', 'config/initializers/mangopay.rb'
22
+ rescue => e
23
+ puts e.message
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ def client_id_valid?
30
+ check_client_id_validity
31
+ check_client_id_availablility
32
+ end
33
+
34
+ def check_client_id_validity
35
+ if (/^[a-z0-9_-]{4,20}$/ =~ client_id).nil?
36
+ raise "The client_id must match the regexp ^[a-z0-9_-]{4,20}$"
37
+ end
38
+ end
39
+
40
+ def check_client_id_availablility
41
+ client = create_client
42
+ if client['Type'] == 'ClientID_already_exist'
43
+ raise client['Message']
44
+ end
45
+ client
46
+ end
47
+
48
+ def create_client
49
+ MangoPay.configure do |c|
50
+ c.preproduction = options[:preproduction]
51
+ end
52
+ MangoPay::Client.create({
53
+ ClientID: client_id,
54
+ Name: client_name,
55
+ Email: client_email
56
+ })
57
+ end
58
+ end
59
+ end
60
+ end