openpay 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +13 -5
  2. data/.gitignore +1 -0
  3. data/.idea/.rakeTasks +2 -2
  4. data/.idea/OpenPay.iml +30 -20
  5. data/.idea/runConfigurations/Run_spec__bankaccounts_spec___OpenPay.xml +1 -0
  6. data/.idea/runConfigurations/Run_spec__cards_spec___OpenPay.xml +1 -0
  7. data/.idea/runConfigurations/Run_spec__charges_spec___OpenPay.xml +1 -0
  8. data/.idea/runConfigurations/Run_spec__customers_spec___OpenPay.xml +1 -0
  9. data/.idea/runConfigurations/Run_spec__exceptions_spec___OpenPay.xml +1 -0
  10. data/.idea/runConfigurations/Run_spec__fees_spec___OpenPay.xml +1 -0
  11. data/.idea/runConfigurations/Run_spec__payouts_spec___OpenPay.xml +1 -0
  12. data/.idea/runConfigurations/Run_spec__plans_spec___OpenPay.xml +1 -0
  13. data/.idea/runConfigurations/Run_spec__subscriptions_spec___OpenPay.xml +1 -0
  14. data/.idea/runConfigurations/Run_spec__transfers_spec___OpenPay.xml +1 -0
  15. data/.idea/runConfigurations/all_specs.xml +1 -0
  16. data/.idea/workspace.xml +484 -268
  17. data/Gemfile +0 -6
  18. data/README.md +111 -29
  19. data/lib/openpay.rb +7 -3
  20. data/lib/openpay/bankaccounts.rb +10 -11
  21. data/lib/openpay/cards.rb +12 -14
  22. data/lib/openpay/charges.rb +38 -14
  23. data/lib/openpay/customers.rb +73 -67
  24. data/lib/openpay/errors/openpay_exception_factory.rb +14 -26
  25. data/lib/openpay/fees.rb +1 -1
  26. data/lib/openpay/open_pay_resource.rb +77 -77
  27. data/lib/openpay/open_pay_resource_factory.rb +1 -1
  28. data/lib/openpay/openpay_api.rb +6 -16
  29. data/lib/openpay/payouts.rb +13 -17
  30. data/lib/openpay/plans.rb +1 -7
  31. data/lib/openpay/subscriptions.rb +21 -29
  32. data/lib/openpay/transfers.rb +14 -18
  33. data/lib/openpay/utils/search_params.rb +20 -0
  34. data/lib/version.rb +1 -2
  35. data/openpay.gemspec +0 -8
  36. data/test/Factories.rb +80 -126
  37. data/test/spec/bankaccounts_spec.rb +55 -61
  38. data/test/spec/cards_spec.rb +56 -76
  39. data/test/spec/charges_spec.rb +89 -84
  40. data/test/spec/customers_spec.rb +37 -47
  41. data/test/spec/exceptions_spec.rb +4 -21
  42. data/test/spec/fees_spec.rb +51 -7
  43. data/test/spec/payouts_spec.rb +102 -65
  44. data/test/spec/plans_spec.rb +27 -50
  45. data/test/spec/subscriptions_spec.rb +87 -24
  46. data/test/spec/transfers_spec.rb +42 -44
  47. data/test/spec/utils/search_params_spec.rb +36 -0
  48. data/test/spec_helper.rb +1 -5
  49. metadata +15 -55
  50. data/lib/OpenPay/Cards.rb +0 -75
  51. data/lib/OpenPay/Charges.rb +0 -77
  52. data/lib/OpenPay/Customers.rb +0 -194
  53. data/lib/OpenPay/Fees.rb +0 -5
  54. data/lib/OpenPay/Payouts.rb +0 -59
  55. data/lib/OpenPay/Plans.rb +0 -23
  56. data/lib/OpenPay/Subscriptions.rb +0 -58
  57. data/lib/OpenPay/Transfers.rb +0 -43
  58. data/lib/OpenPay/bankaccounts.rb +0 -59
  59. data/lib/OpenPay/errors/openpay_connection_exception.rb +0 -3
  60. data/lib/OpenPay/errors/openpay_exception.rb +0 -29
  61. data/lib/OpenPay/errors/openpay_exception_factory.rb +0 -60
  62. data/lib/OpenPay/errors/openpay_transaction_exception.rb +0 -5
  63. data/lib/OpenPay/open_pay_resource.rb +0 -242
  64. data/lib/OpenPay/open_pay_resource_factory.rb +0 -10
  65. data/lib/OpenPay/openpay_api.rb +0 -58
@@ -1,10 +0,0 @@
1
- class OpenPayResourceFactory
2
- def OpenPayResourceFactory::create(resource,merchant_id,private_key,production)
3
- begin
4
- Object.const_get(resource.capitalize).new(merchant_id,private_key,production)
5
- rescue NameError
6
- raise OpenpayException.new("Invalid resource name:#{resource}",false)
7
- end
8
- end
9
- end
10
-
@@ -1,58 +0,0 @@
1
- require 'logger'
2
- require 'base64'
3
- require 'rest-client'
4
- require 'uri'
5
-
6
- require 'openpay/open_pay_resource_factory'
7
- require 'errors/openpay_exception'
8
-
9
- LOG= Logger.new(STDOUT)
10
- #change to Logger::DEBUG if need trace information
11
- #due the nature of the information, we recommend to never use a log file when in debug
12
- LOG.level=Logger::ERROR
13
-
14
- class OpenpayApi
15
- #API Endpoints
16
- API_DEV='https://sandbox-api.openpay.mx/v1/'
17
- API_PROD='https://api.openpay.mx/v1/'
18
-
19
- #by default the testing environment is used
20
- def initialize(merchant_id, private_key,production=false)
21
- @merchant_id=merchant_id
22
- @private_key=private_key
23
- @production=production
24
- end
25
-
26
-
27
- # @return [nil]
28
- def create(resource)
29
- klass=OpenPayResourceFactory::create(resource, @merchant_id,@private_key,@production)
30
- #attach api hook to be able to refere to same API instance from created resources
31
- #TODO we may move it to the initialize method
32
- klass.api_hook=self
33
- klass
34
- end
35
-
36
-
37
- def OpenpayApi::base_url(production)
38
- if production
39
- API_PROD
40
- else
41
- API_DEV
42
- end
43
- end
44
-
45
-
46
- def env
47
- if @production
48
- :production
49
- else
50
- :test
51
- end
52
- end
53
-
54
-
55
-
56
-
57
-
58
- end