moneta-api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +3 -0
  4. data/.yardopts +6 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +31 -0
  8. data/Rakefile +2 -0
  9. data/lib/moneta/api/data_mapper.rb +91 -0
  10. data/lib/moneta/api/requests/authorise_transaction_batch_request.rb +9 -0
  11. data/lib/moneta/api/requests/authorise_transaction_request.rb +15 -0
  12. data/lib/moneta/api/requests/cancel_transaction_batch_request.rb +10 -0
  13. data/lib/moneta/api/requests/cancel_transaction_request.rb +14 -0
  14. data/lib/moneta/api/requests/confirm_transaction_batch_request.rb +10 -0
  15. data/lib/moneta/api/requests/confirm_transaction_request.rb +9 -0
  16. data/lib/moneta/api/requests/create_account_request.rb +65 -0
  17. data/lib/moneta/api/requests/find_accounts_list_request.rb +38 -0
  18. data/lib/moneta/api/requests/find_last_operations_list_request.rb +24 -0
  19. data/lib/moneta/api/requests/find_operations_list_request.rb +26 -0
  20. data/lib/moneta/api/requests/forecast_transaction_request.rb +9 -0
  21. data/lib/moneta/api/requests/get_account_payment_password_challenge_request.rb +16 -0
  22. data/lib/moneta/api/requests/invoice_batch_request.rb +10 -0
  23. data/lib/moneta/api/requests/invoice_request.rb +10 -0
  24. data/lib/moneta/api/requests/payment_request.rb +9 -0
  25. data/lib/moneta/api/requests/refund_request.rb +42 -0
  26. data/lib/moneta/api/requests/transfer_request.rb +9 -0
  27. data/lib/moneta/api/requests/verify_payment_request.rb +10 -0
  28. data/lib/moneta/api/requests/verify_transaction_request.rb +51 -0
  29. data/lib/moneta/api/requests/verify_transfer_request.rb +10 -0
  30. data/lib/moneta/api/response_factory.rb +22 -0
  31. data/lib/moneta/api/responses/authorise_transaction_batch_response.rb +17 -0
  32. data/lib/moneta/api/responses/authorise_transaction_response.rb +10 -0
  33. data/lib/moneta/api/responses/cancel_transaction_batch_response.rb +17 -0
  34. data/lib/moneta/api/responses/cancel_transaction_response.rb +10 -0
  35. data/lib/moneta/api/responses/confirm_transaction_batch_response.rb +17 -0
  36. data/lib/moneta/api/responses/confirm_transaction_response.rb +10 -0
  37. data/lib/moneta/api/responses/create_account_response.rb +19 -0
  38. data/lib/moneta/api/responses/find_account_by_alias_response.rb +16 -0
  39. data/lib/moneta/api/responses/find_account_by_id_response.rb +16 -0
  40. data/lib/moneta/api/responses/find_accounts_list_response.rb +15 -0
  41. data/lib/moneta/api/responses/find_last_operations_list_response.rb +12 -0
  42. data/lib/moneta/api/responses/find_operations_list_response.rb +12 -0
  43. data/lib/moneta/api/responses/forecast_transaction_response.rb +16 -0
  44. data/lib/moneta/api/responses/get_account_payment_password_challenge_response.rb +16 -0
  45. data/lib/moneta/api/responses/get_operation_details_by_id_response.rb +15 -0
  46. data/lib/moneta/api/responses/invoice_batch_response.rb +17 -0
  47. data/lib/moneta/api/responses/invoice_response.rb +10 -0
  48. data/lib/moneta/api/responses/payment_response.rb +10 -0
  49. data/lib/moneta/api/responses/refund_response.rb +10 -0
  50. data/lib/moneta/api/responses/transfer_response.rb +9 -0
  51. data/lib/moneta/api/responses/verify_payment_response.rb +10 -0
  52. data/lib/moneta/api/responses/verify_transaction_response.rb +10 -0
  53. data/lib/moneta/api/responses/verify_transfer_response.rb +10 -0
  54. data/lib/moneta/api/service.rb +18 -0
  55. data/lib/moneta/api/service_methods.rb +150 -0
  56. data/lib/moneta/api/types/account_access_info.rb +24 -0
  57. data/lib/moneta/api/types/account_info.rb +72 -0
  58. data/lib/moneta/api/types/authorise_transaction_batch_request_type.rb +47 -0
  59. data/lib/moneta/api/types/authorise_transaction_request_type.rb +19 -0
  60. data/lib/moneta/api/types/cancel_transaction_batch_request_type.rb +42 -0
  61. data/lib/moneta/api/types/cancel_transaction_batch_response_type.rb +29 -0
  62. data/lib/moneta/api/types/cancel_transaction_request_type.rb +24 -0
  63. data/lib/moneta/api/types/cancel_transaction_response_type.rb +20 -0
  64. data/lib/moneta/api/types/confirm_transaction_batch_request_type.rb +47 -0
  65. data/lib/moneta/api/types/confirm_transaction_request_type.rb +53 -0
  66. data/lib/moneta/api/types/entity.rb +15 -0
  67. data/lib/moneta/api/types/find_operations_list_request_filter.rb +102 -0
  68. data/lib/moneta/api/types/forecast_transaction_response_type.rb +52 -0
  69. data/lib/moneta/api/types/invoice_batch_request_type.rb +46 -0
  70. data/lib/moneta/api/types/invoice_request_type.rb +49 -0
  71. data/lib/moneta/api/types/key_value_attribute.rb +18 -0
  72. data/lib/moneta/api/types/operation_info.rb +88 -0
  73. data/lib/moneta/api/types/operation_info_batch_response_type.rb +27 -0
  74. data/lib/moneta/api/types/operation_info_list.rb +41 -0
  75. data/lib/moneta/api/types/pager.rb +22 -0
  76. data/lib/moneta/api/types/payment_request_type.rb +58 -0
  77. data/lib/moneta/api/types/transaction_batch_response_type.rb +29 -0
  78. data/lib/moneta/api/types/transaction_request_type.rb +55 -0
  79. data/lib/moneta/api/types/transaction_response_type.rb +28 -0
  80. data/lib/moneta/api/types/verify_transaction_response_type.rb +18 -0
  81. data/lib/moneta/api/types/verify_transfer_response_type.rb +32 -0
  82. data/lib/moneta/api/version.rb +5 -0
  83. data/lib/moneta/api.rb +23 -0
  84. data/moneta-api.gemspec +31 -0
  85. data/spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb +71 -0
  86. data/spec/lib/moneta/api/requests/authorise_transaction_request_spec.rb +22 -0
  87. data/spec/lib/moneta/api/requests/create_account_request_spec.rb +16 -0
  88. data/spec/lib/moneta/api/requests/find_operations_list_request_spec.rb +23 -0
  89. data/spec/lib/moneta/api/requests/forecast_transaction_request_spec.rb +19 -0
  90. data/spec/lib/moneta/api/requests/get_account_payment_password_challenge_request_spec.rb +15 -0
  91. data/spec/lib/moneta/api/requests/payment_request_spec.rb +22 -0
  92. data/spec/lib/moneta/api/requests/transfer_request_spec.rb +19 -0
  93. data/spec/lib/moneta/api/response/find_account_by_id_spec.rb +10 -0
  94. data/spec/lib/moneta/api/service_spec.rb +9 -0
  95. data/spec/lib/moneta/api/types/operation_info_spec.rb +23 -0
  96. data/spec/spec_helper.rb +36 -0
  97. data/spec/support/matchers.rb +7 -0
  98. data/spec/support/wsdl +7743 -0
  99. data/spec/vcr/moneta_api_requests_authorisetransactionbatchrequest/use_when_one_operation_transaction_transaction_.yml +10790 -0
  100. data/spec/vcr/moneta_api_requests_authorisetransactionbatchrequest/use_when_two_operations_transaction_first_transaction_.yml +10790 -0
  101. data/spec/vcr/moneta_api_requests_authorisetransactionrequest_authorise_transaction/should_success.yml +10790 -0
  102. data/spec/vcr/moneta_api_requests_createaccountrequest/create_account_account_id_.yml +10789 -0
  103. data/spec/vcr/moneta_api_requests_findoperationslistrequest/find_operations_list_account_id_.yml +10794 -0
  104. data/spec/vcr/moneta_api_requests_forecasttransactionrequest/forecast_transaction_payer_currency_.yml +10802 -0
  105. data/spec/vcr/moneta_api_requests_getaccountpaymentpasswordchallengerequest/get_account_payment_password_challenge_.yml +10790 -0
  106. data/spec/vcr/moneta_api_requests_paymentrequest/payment_should_success.yml +10789 -0
  107. data/spec/vcr/moneta_api_requests_transferrequest/transfer_status_.yml +10789 -0
  108. data/spec/vcr/moneta_api_service_find_account_by_id/account_id_.yml +10789 -0
  109. metadata +302 -0
@@ -0,0 +1,41 @@
1
+ module Moneta
2
+ module Api
3
+ module Types
4
+ # Тип, представляющий список операций.
5
+ # Содержит разбиение по страницам для отображения длинных списков.
6
+ # Transaction list type.
7
+ # Contains paged structure for long list presentation.
8
+
9
+ class OperationInfoList
10
+ include Moneta::Api::DataMapper
11
+
12
+ # @return [Integer] Количество операций, возвращаемых в результате запроса.
13
+ # / Transaction per page within one request.
14
+ property :page_size
15
+
16
+ # @return [Integer] Номер текущей страницы. Нумерация начинается с 1
17
+ # / Current page number starting with 1.
18
+ property :page_number
19
+
20
+ # @return [Integer] Максимальное количество страниц с операциями по данному запросу
21
+ # / Total page count for given request.
22
+ property :pages_count
23
+
24
+ # @return [Integer] Количество операций на текущей странице.
25
+ # Меньше или равно pageSize.
26
+ # Последняя страница может содержать операций меньше, чем pageSize.
27
+ # / Transactions count in current page. Less or equal to pageSize. Last page may contain less than pageSize transactions.
28
+ property :size
29
+
30
+ # @return [Integer] Общее количество операций, которое можно получить в данной
31
+ # выборке
32
+ # / Total transactions count for given request.
33
+ property :total_size
34
+
35
+ # @return [Array[MonetaOperationInfo]] Список операций
36
+ # / Transaction list
37
+ property :operation, Moneta::Api::Types::OperationInfo
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,22 @@
1
+ module Moneta
2
+ module Api
3
+ module Types
4
+ # Тип, позволяющий задать необходимую страницу при отображении длинных списков.
5
+ # Long list retrieval type.
6
+
7
+ class Pager
8
+ include Moneta::Api::DataMapper
9
+
10
+ # @return [Int] Номер страницы, которую нужно получить. Минимальное значение равно 1.
11
+ # Значение по умолчанию равно 1.
12
+ # / Page number to retrieve. Minimal value is 1. By default is 1.
13
+ property :page_number
14
+
15
+ # @return [Int] Сколько записей необходимо получить на одной странице. Минимальное
16
+ # значение равно 1. Максимальное значение равно 100. Значение по умолчанию равно 10.
17
+ # / Transactions per page. Minimal value is 1. Maximal value is 100. By default is 10.
18
+ property :page_size
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,58 @@
1
+ module Moneta
2
+ module Api
3
+ module Types
4
+ # Тип, описывающий параметры операции в запросах. Отличается от TransactionRequestType тем, что в качестве получателя можно указывать не только номер счета.
5
+ # Transaction parameters type for requests. The difference from TransactionRequestType is that payee may be addressed not only by account number rather than transaction ID, e-mail address or phone number.
6
+
7
+ class PaymentRequestType < Entity
8
+ # @return [Integer] Номер счета плательщика
9
+ # / Payer account number
10
+ property :payer
11
+
12
+ # @return [String] Может принимать следующие значения:
13
+ # E-mail получателя. Сумма зачисляется на "основной счет" получателя, найденного по данному E-mail# Номер операции - если значение этого поля начинается с "0". То есть значение 012345678 означает оплату операции 12345678
14
+ # Телефон получателя - если значение этого поля начинается со знака "+". Сумма зачисляется на "основной счет" получателя, найденного по данному телефону
15
+ # Номер счета получателя
16
+ # / Content based semantic is as follows: E-mail address of payee. The amount is credited to primary account found by given e-mail address. Transaction ID prefixed with "0" (zero). For example, 012345678 means transaction 12345678. Phone number of payee prefixed with "+" (plus). The amount is credited to primary account found by given phone number. Account number of payee: 8 digits not starting with "0" (zero).
17
+ property :payee
18
+
19
+ # @return [Float] Сумма операции.
20
+ # Если флаг isPayerAmount отсутствует
21
+ # и пользователь имеет доступ только к счету плательщика,
22
+ # то интерпретируется как сумма к списанию (в валюте плательщика).
23
+ # Если флаг isPayerAmount отсутствует
24
+ # и пользователь имеет доступ только к счету получателя,
25
+ # то интерпретируется как сумма к зачислению (в валюте получателя).
26
+ # / Transaction amount. If isPayerAmount is omitted and user has access only to payer account, then is interpreted as debit amount (in payer's currency). If isPayerAmount is omitted and user has access only to payee account, then is interpreted as credit amount (in payee's currency).
27
+ property :amount
28
+
29
+ # @return [Boolean] Если пользователь имеет доступ как к счету плательщика, так и счету получателя,
30
+ # то флаг isPayerAmount обязателен.
31
+ # Если флаг isPayerAmount установлен (true), то amount используется как сумма к списанию (в валюте плательщика).
32
+ # Если флаг isPayerAmount сброшен (false), то amount используется как сумма к зачислению (в валюте получателя).
33
+ # / If user has access to both accounts, then isPayerAmount flag is obligatory. If isPayerAmount flag is "true", then amount is used as debit amount (in payer's currency). If isPayerAmount flag is "false", then amount is used as credit amount (in payee's currency).
34
+ property :is_payer_amount
35
+
36
+ # @return [String] Платежный пароль счета плательщика
37
+ # / Payment password for payer account
38
+ property :payment_password
39
+
40
+ # @return [String] Внешний номер операции
41
+ # / External transaction ID
42
+ property :client_transaction
43
+
44
+ # @return [String] Описание операции
45
+ # / Transaction description or comments
46
+ property :description
47
+
48
+ # @return [OperationInfo] Набор полей, которые необходимо сохранить в качестве атрибутов операции. Значения дат в формате dd.MM.yyyy HH:mm:ss
49
+ # / Key-value pairs that will be saved as a transaction attributes. Use format dd.MM.yyyy HH:mm:ss for date values
50
+ property :operation_info, Moneta::Api::Types::OperationInfo
51
+
52
+ # @return [String] Запрос для платежного пароля
53
+ # / Payment password challenge
54
+ property :payment_password_challenge
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,29 @@
1
+ require_relative 'transaction_response_type'
2
+
3
+ module Moneta
4
+ module Api
5
+ module Types
6
+ # Тип, описывающий атрибуты операции в ответах в пакетном запросе.
7
+ # Transaction attributes type for responses in batch processing mode.
8
+
9
+ class TransactionBatchResponseType
10
+ include Moneta::Api::DataMapper
11
+
12
+ # @return [String] Поле содержит описание ошибки, если операция не была проведена.
13
+ # В этом случае поле transaction - пустое. Если операция проведена,
14
+ # то поле error пустое, а поле transaction содержит детали операции.
15
+ # / Error description in case of tranfer processing failure. If transfer processed successfully "error" is empty and "transaction" element contains transaction details.
16
+ property :error
17
+
18
+ # @return [Moneta::Api::Types::TransactionResponseType]
19
+ property :transaction, Types::TransactionResponseType
20
+
21
+ # @return [String] Поле содержит код ошибки. Поле заполнено только тогда, когда есть описание ошибки в поле error.
22
+ # Для получения этого поля в запросе необходимо выставлять атрибут version равный или больше VERSION_2.
23
+ # Коды ошибок совпадают со значением элемента faultDetail (смотрите описание для этого элемента).
24
+ # / The field contains error code. The field "errorCode" is specified if the field "error" is present and contains error description. For retrieving errorCode the request attribute "version" has to be set to "VERSION_2" or grater. Error codes values correspond to "faultDetail" description.
25
+ property :error_code
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,55 @@
1
+ module Moneta
2
+ module Api
3
+ module Types
4
+ # Тип, описывающий параметры операции в запросах.
5
+ # Transaction parameters type for requests.
6
+
7
+ class TransactionRequestType < Entity
8
+ # @return [Integer] Номер счета плательщика
9
+ # / Payer account number
10
+ property :payer
11
+
12
+ # @return [Integer] Номер счета получателя
13
+ # / Payee account number
14
+ property :payee
15
+
16
+ # @return [Float] Сумма операции.
17
+ # Если флаг isPayerAmount отсутствует
18
+ # и пользователь имеет доступ только к счету плательщика,
19
+ # то интерпретируется как сумма к списанию (в валюте плательщика).
20
+ # Если флаг isPayerAmount отсутствует
21
+ # и пользователь имеет доступ только к счету получателя,
22
+ # то интерпретируется как сумма к зачислению (в валюте получателя).
23
+ # / Transaction amount. If isPayerAmount is omitted and user has access only to payer account, then is interpreted as debit amount (in payer's currency). If isPayerAmount is omitted and user has access only to payee account, then is interpreted as credit amount (in payee's currency).
24
+ property :amount
25
+
26
+ # @return [Boolean] Если пользователь имеет доступ как к счету плательщика, так и счету получателя,
27
+ # то флаг isPayerAmount обязателен.
28
+ # Если флаг isPayerAmount установлен (true), то amount используется как сумма к списанию (в валюте плательщика).
29
+ # Если флаг isPayerAmount сброшен (false), то amount используется как сумма к зачислению (в валюте получателя).
30
+ # / If user has access to both accounts, then isPayerAmount flag is obligatory. If isPayerAmount flag is "true", then amount is used as debit amount (in payer's currency). If isPayerAmount flag is "false", then amount is used as credit amount (in payee's currency).
31
+ property :is_payer_amount
32
+
33
+ # @return [Normalized] Платежный пароль счета плательщика
34
+ # / Payment password for payer account
35
+ property :payment_password
36
+
37
+ # @return [String] Внешний номер операции
38
+ # / External transaction ID
39
+ property :client_transaction
40
+
41
+ # @return [String] Описание операции
42
+ # / Transaction description or comments
43
+ property :description
44
+
45
+ # @return [OperationInfo] Набор полей, которые необходимо сохранить в качестве атрибутов операции. Значения дат в формате dd.MM.yyyy HH:mm:ss
46
+ # / Key-value pairs that will be saved as a transaction attributes. Use format dd.MM.yyyy HH:mm:ss for date values
47
+ property :operation_info, Moneta::Api::Types::OperationInfo
48
+
49
+ # @return [String] Запрос для платежного пароля
50
+ # / Payment password challenge
51
+ property :payment_password_challenge
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,28 @@
1
+ module Moneta
2
+ module Api
3
+ module Types
4
+ # Тип, описывающий атрибуты операции в ответах.
5
+ # Transaction attributes type for responses.
6
+
7
+ class TransactionResponseType
8
+ include Moneta::Api::DataMapper
9
+
10
+ # @return [String] Текущий статус операции
11
+ # / Current transaction status
12
+ property :status
13
+
14
+ # @return [Date] Время последней модификации операции
15
+ # / Transaction modification timestamp
16
+ property :date_time
17
+
18
+ # @return [Integer] Номер операции
19
+ # / Transaction ID in MONETA.RU
20
+ property :transaction
21
+
22
+ # @return [String] Внешний номер операции
23
+ # / External transaction ID
24
+ property :client_transaction
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ module Moneta
2
+ module Api
3
+ module Types
4
+ # Ответ на запрос проверки проведения операции в системе МОНЕТА.РУ
5
+ # Transaction verification response.
6
+
7
+ class VerifyTransactionResponseType < VerifyTransferResponseType
8
+ # @return [Integer] Идентификатор операции в системе МОНЕТА.РУ.
9
+ # / The identifier of transaction.
10
+ property :transaction_id
11
+
12
+ # @return [String] Статус операции в системе МОНЕТА.РУ.
13
+ # / Transaction status type in MONETA.RU
14
+ property :operation_status
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ module Moneta
2
+ module Api
3
+ module Types
4
+ # Тип, описывающий состояние операции в системе МОНЕТА.РУ
5
+ # Type describes verification status of transaction.
6
+
7
+ class VerifyTransferResponseType
8
+ include Moneta::Api::DataMapper
9
+
10
+ # @return [Boolean] Если поле равно true, то данная операция может
11
+ # быть проведена в системе МОНЕТА.РУ
12
+ # / If true the transaction may be processed in MONETA.RU
13
+ property :is_transaction_valid
14
+
15
+ # @return [String] Описание текущего статуса операции.
16
+ # / Description of current transaction status.
17
+ property :description
18
+
19
+ # @return [ForecastTransactionResponseType] Если операция может быть проведена, то в данном поле содержатся детали операции.
20
+ # Иначе - это поле пустое.
21
+ # / Additional information if transaction may be processed. Otherwise empty.
22
+ property :forecast, ForecastTransactionResponseType
23
+
24
+ # @return [String] Поле содержит код ошибки. Поле заполнено только тогда, когда есть описание ошибки в поле description.
25
+ # Для получения этого поля в запросе необходимо выставлять атрибут version равный или больше VERSION_2.
26
+ # Коды ошибок совпадают со значением элемента faultDetail (смотрите описание для этого элемента).
27
+ # / The field contains error code. The field "errorCode" is specified if the field "description" is present and contains error description. For retrieving errorCode the request attribute "version" has to be set to "VERSION_2" or grater. Error codes values correspond to "faultDetail" description.
28
+ property :error_code
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module Moneta
2
+ module Api
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
data/lib/moneta/api.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'moneta/api/version'
2
+ require 'savon'
3
+
4
+ require 'moneta/api/service_methods'
5
+ require 'moneta/api/service'
6
+ require 'moneta/api/data_mapper'
7
+
8
+ require 'moneta/api/types/entity'
9
+ require 'moneta/api/types/key_value_attribute'
10
+ require 'moneta/api/types/operation_info'
11
+ require 'moneta/api/types/transaction_request_type'
12
+
13
+ require 'moneta/api/types/forecast_transaction_response_type'
14
+ require 'moneta/api/types/verify_transfer_response_type'
15
+
16
+ %w(types responses requests).each do |folder|
17
+ Dir["lib/moneta/api/#{ folder }/*.rb"].each do |file|
18
+ require File.join(File.dirname(__FILE__), '../../', file)
19
+ end
20
+ end
21
+
22
+ require 'moneta/api/response_factory'
23
+
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'moneta/api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'moneta-api'
8
+ spec.version = Moneta::Api::VERSION
9
+ spec.authors = ['ssnikolay']
10
+ spec.email = ['ssnikolay@gmail.com']
11
+ spec.summary = 'МОНЕТА.РУ (MONETA.MerchantAPI.v2)'
12
+ spec.description = 'МОНЕТА.РУ (MONETA.MerchantAPI.v2).'
13
+ spec.homepage = 'https://www.moneta.ru/doc/MONETA.MerchantAPI.v2.ru.pdf'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'savon', '~> 2.10.0'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.7'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'pry'
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'rspec-its'
28
+ spec.add_development_dependency 'vcr'
29
+ spec.add_development_dependency 'fakeweb'
30
+ spec.add_development_dependency 'yard'
31
+ end
@@ -0,0 +1,71 @@
1
+ describe Moneta::Api::Requests::AuthoriseTransactionBatchRequest do
2
+ describe 'Entity extension' do
3
+ subject { described_class.new.properties.keys }
4
+
5
+ it { is_expected.to be_include(:version) }
6
+ it { is_expected.to be_include(:transactional) }
7
+ end
8
+
9
+ describe '#add_transaction' do
10
+ let(:request) { described_class.new }
11
+ let(:add_transaction) { request.add_transaction(item) }
12
+
13
+ context 'when valid item' do
14
+ let(:item) { Moneta::Api::Requests::PaymentRequest.new }
15
+
16
+ it 'should success add' do
17
+ add_transaction
18
+ expect(request.transaction.count).to eq 1
19
+ end
20
+ end
21
+
22
+ context 'when invalid item' do
23
+ let(:item) { Hash.new }
24
+
25
+ it { expect { add_transaction }.to raise_error }
26
+ end
27
+ end
28
+
29
+ describe 'use', vcr: true do
30
+ let(:service) { Moneta::Api::Service.new($username, $password) }
31
+ let(:data) {
32
+ {
33
+ amount: 10,
34
+ payee: 28988504,
35
+ payer: 10999,
36
+ is_payer_amount: false,
37
+ payment_password: '12345'
38
+ }
39
+ }
40
+ let(:request) do
41
+ described_class.new.tap do |request|
42
+ request.transactional = false
43
+ request.exit_on_failure = true
44
+ operations.each { |o| request.add_transaction(o) }
45
+ end
46
+ end
47
+
48
+ subject { service.authorise_transaction_batch(request) }
49
+
50
+ context 'when one operation' do
51
+ let(:operations) do
52
+ [
53
+ Moneta::Api::Requests::TransferRequest.build(data)
54
+ ]
55
+ end
56
+
57
+ its('transaction.transaction') { is_expected.to be_a_kind_of(Moneta::Api::Types::OperationInfo) }
58
+ end
59
+
60
+ context 'when two operations' do
61
+ let(:operations) do
62
+ [
63
+ Moneta::Api::Requests::TransferRequest.build(data),
64
+ Moneta::Api::Requests::TransferRequest.build(data)
65
+ ]
66
+ end
67
+
68
+ its('transaction.first.transaction') { is_expected.to be_a_kind_of(Moneta::Api::Types::OperationInfo) }
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,22 @@
1
+ describe Moneta::Api::Requests::AuthoriseTransactionRequest, vcr: true do
2
+ let(:service) { Moneta::Api::Service.new($username, $password) }
3
+
4
+ describe '#authorise_transaction' do
5
+ let(:request) do
6
+ described_class.new.tap do |request|
7
+ request.payee = 28988504
8
+ request.payer = 10999
9
+ request.amount = 10
10
+ request.is_payer_amount = false
11
+ request.payment_password = '12345'
12
+ end
13
+ end
14
+
15
+ let!(:response) { service.authorise_transaction(request) }
16
+
17
+ it 'should success' do
18
+ expect(response).to be_kind_of(Moneta::Api::Responses::AuthoriseTransactionResponse)
19
+ expect(response.id).to be_a_moneta_id
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,16 @@
1
+ describe Moneta::Api::Requests::CreateAccountRequest, vcr: true do
2
+ let(:service) { Moneta::Api::Service.new($username, $password) }
3
+
4
+ describe 'create account' do
5
+ let(:request) do
6
+ described_class.new.tap do |request|
7
+ request.currency = 'RUB'
8
+ request.payment_password = '12345'
9
+ end
10
+ end
11
+
12
+ subject { service.create_account(request) }
13
+
14
+ its(:account_id) { is_expected.to be_a_moneta_id }
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ describe Moneta::Api::Requests::FindOperationsListRequest, vcr: true do
2
+ let(:service) { Moneta::Api::Service.new($username, $password) }
3
+
4
+ describe 'find_operations_list' do
5
+ let(:request) do
6
+ described_class.new.tap do |request|
7
+ request.filter = Moneta::Api::Types::FindOperationsListRequestFilter.new.tap do |r|
8
+ r.date_from = '2015-01-01T00:00:00+03:00'
9
+ r.date_to = '2015-04-13T00:00:00+03:00'
10
+ end
11
+
12
+ request.pager = Moneta::Api::Types::Pager.new.tap do |r|
13
+ r.page_number = 1
14
+ r.page_size = 1
15
+ end
16
+ end
17
+ end
18
+
19
+ subject { service.find_operations_list(request) }
20
+
21
+ its(:account_id) { pending; is_expected.to be_a_moneta_id }
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ describe Moneta::Api::Requests::ForecastTransactionRequest, vcr: true do
2
+ let(:service) { Moneta::Api::Service.new($username, $password) }
3
+
4
+ describe 'forecast_transaction' do
5
+ let(:request) do
6
+ described_class.new.tap do |request|
7
+ request.amount = 10
8
+ request.payee = 28988504
9
+ request.payer = 10999
10
+ request.is_payer_amount = false
11
+ request.payment_password = '12345'
12
+ end
13
+ end
14
+
15
+ subject { service.forecast_transaction(request) }
16
+
17
+ its(:payer_currency) { is_expected.to eq 'RUB' }
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ describe Moneta::Api::Requests::GetAccountPaymentPasswordChallengeRequest, vcr: true do
2
+ let(:service) { Moneta::Api::Service.new($username, $password) }
3
+
4
+ describe 'get_account_payment_password_challenge' do
5
+ let(:request) do
6
+ described_class.new.tap do |request|
7
+ request.account_id = 28988504
8
+ end
9
+ end
10
+
11
+ subject { service.get_account_payment_password_challenge(request) }
12
+
13
+ it { is_expected.to be_kind_of(Moneta::Api::Responses::GetAccountPaymentPasswordChallengeResponse) }
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ describe Moneta::Api::Requests::PaymentRequest, vcr: true do
2
+ let(:service) { Moneta::Api::Service.new($username, $password) }
3
+
4
+ describe 'payment' do
5
+ let(:request) do
6
+ described_class.new.tap do |request|
7
+ request.payee = 28988504
8
+ request.payer = 10999
9
+ request.amount = 10
10
+ request.is_payer_amount = false
11
+ request.payment_password = '12345'
12
+ end
13
+ end
14
+
15
+ let!(:response) { service.payment(request) }
16
+
17
+ it 'should success' do
18
+ expect(response.attribute.first).to be_kind_of(Moneta::Api::Types::KeyValueAttribute)
19
+ expect(response.id).to be_a_moneta_id
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ describe Moneta::Api::Requests::TransferRequest, vcr: true do
2
+ let(:service) { Moneta::Api::Service.new($username, $password) }
3
+
4
+ describe 'transfer' do
5
+ let(:request) do
6
+ described_class.new.tap do |request|
7
+ request.amount = 10
8
+ request.payee = 28988504
9
+ request.payer = 10999
10
+ request.is_payer_amount = false
11
+ request.payment_password = '12345'
12
+ end
13
+ end
14
+
15
+ subject { service.transfer(request) }
16
+
17
+ its(:status) { is_expected.to eq 'SUCCEED' }
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ describe Moneta::Api::Responses::FindAccountByIdResponse do
2
+ describe '#load_from' do
3
+ subject { described_class.build(account: { id: '10999' }) }
4
+
5
+ it 'should fill account info' do
6
+ expect(subject.account).to be_kind_of(Moneta::Api::Types::AccountInfo)
7
+ expect(subject.account.id).to eq('10999')
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ describe Moneta::Api::Service, vcr: true do
2
+ let(:service) { described_class.new($username, $password) }
3
+
4
+ describe '#find_account_by_id' do
5
+ subject { service.find_account_by_id(10999) }
6
+
7
+ its('account.id') { is_expected.to eq '10999' }
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ describe Moneta::Api::Types::OperationInfo do
2
+ let(:operation_info) { described_class.new }
3
+
4
+ describe '#add_attribute' do
5
+ subject {
6
+ operation_info.attribute
7
+ operation_info.add_attribute(item)
8
+ operation_info.attribute
9
+ }
10
+
11
+ context 'when item instance of Moneta::Api::Types::KeyValueAttribute' do
12
+ let(:item) { Moneta::Api::Types::KeyValueAttribute.new.fill(key: 'key', value: 'value') }
13
+
14
+ its(:count) { is_expected.to eq 1 }
15
+ end
16
+
17
+ context 'when wrong item' do
18
+ let(:item) { String.new }
19
+
20
+ it { expect{ subject }.to raise_error(TypeError) }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ require 'rspec'
2
+ require 'pry'
3
+ require 'rspec/its'
4
+ require 'moneta/api'
5
+ require 'yaml'
6
+ require 'vcr'
7
+
8
+ Dir['spec/support/**/*.rb'].each do |file|
9
+ require File.join(File.dirname(__FILE__), '..', file)
10
+ end
11
+
12
+ config = YAML.load(File.read(File.join(Dir.pwd, 'spec/support/moneta.yml')))
13
+
14
+ $username = config['username']
15
+ $password = config['password']
16
+
17
+ VCR.configure do |config|
18
+ config.cassette_library_dir = File.join(Dir.pwd, 'spec/vcr')
19
+ config.hook_into :fakeweb
20
+ config.filter_sensitive_data('<USERNAME>') { $username }
21
+ config.filter_sensitive_data('<PASSWORD>') { $password }
22
+ end
23
+
24
+ RSpec.configure do |config|
25
+ config.around(:each, :vcr) do |example|
26
+ name = example.metadata[:full_description].split(/\s+/, 2).join('/').downcase.gsub(/[^\w\/]+/, '_')
27
+ options = example.metadata.select{ |key| [ :record, :match_requests_on ].member?(key) }
28
+ VCR.use_cassette(name, options) { example.call }
29
+ end
30
+
31
+ config.before(:each) do
32
+ allow_any_instance_of(Moneta::Api::Service).to receive(:wsdl).and_return(
33
+ Nokogiri::XML(File.read('spec/support/wsdl'))
34
+ )
35
+ end
36
+ end