pagseguro-sdk 2.6.2

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 (324) hide show
  1. checksums.yaml +7 -0
  2. data/.github/.gitignore +204 -0
  3. data/.github/ISSUE_TEMPLATE/relatorio-de-bug.md +29 -0
  4. data/.github/workflows/codacy-analysis.yml +46 -0
  5. data/.gitignore +28 -0
  6. data/.rspec +1 -0
  7. data/.travis.yml +13 -0
  8. data/CHANGELOG.md +95 -0
  9. data/CONTRIBUTING.md +39 -0
  10. data/Dockerfile +20 -0
  11. data/Gemfile +2 -0
  12. data/LICENSE-2.0.txt +177 -0
  13. data/README.md +436 -0
  14. data/Rakefile +5 -0
  15. data/docker-compose.yml +5 -0
  16. data/docs/transparent_checkout.md +201 -0
  17. data/examples/authorization/create_authorization.rb +32 -0
  18. data/examples/authorization/create_authorization_with_account.rb +56 -0
  19. data/examples/authorization/search/search_authorization_by_code.rb +29 -0
  20. data/examples/authorization/search/search_authorization_by_date.rb +35 -0
  21. data/examples/authorization/search/search_authorization_by_notification_code.rb +29 -0
  22. data/examples/authorization/search/search_authorization_by_reference.rb +31 -0
  23. data/examples/boot.rb +26 -0
  24. data/examples/checkout/create_payment_request.rb +63 -0
  25. data/examples/checkout/search/search_abandoned_transactions.rb +41 -0
  26. data/examples/checkout/search/search_transaction_by_code.rb +76 -0
  27. data/examples/checkout/search/search_transaction_by_notification_code.rb +76 -0
  28. data/examples/checkout/search/search_transaction_by_reference.rb +36 -0
  29. data/examples/checkout/search/search_transactions_by_date.rb +45 -0
  30. data/examples/create_session.rb +19 -0
  31. data/examples/direct/create_transaction_using_boleto.rb +100 -0
  32. data/examples/direct/create_transaction_using_credit_card.rb +128 -0
  33. data/examples/direct/create_transaction_using_online_debit.rb +104 -0
  34. data/examples/get_installments.rb +40 -0
  35. data/examples/preapproval/cancel_preapproval.rb +26 -0
  36. data/examples/preapproval/change_preapproval_payment.rb +50 -0
  37. data/examples/preapproval/change_preapproval_status.rb +29 -0
  38. data/examples/preapproval/charge_preapproval.rb +36 -0
  39. data/examples/preapproval/create_preapproval.rb +68 -0
  40. data/examples/preapproval/create_preapproval_auto.rb +53 -0
  41. data/examples/preapproval/create_preapproval_discount.rb +30 -0
  42. data/examples/preapproval/create_preapproval_manual.rb +58 -0
  43. data/examples/preapproval/create_preapproval_transparent.rb +41 -0
  44. data/examples/preapproval/preapproval_retry.rb +29 -0
  45. data/examples/preapproval/search/search_by_date_interval.rb +45 -0
  46. data/examples/preapproval/search/search_by_days_interval.rb +46 -0
  47. data/examples/preapproval/search/search_by_notification_code.rb +50 -0
  48. data/examples/preapproval/search/search_by_subscription_code.rb +50 -0
  49. data/examples/preapproval/search/search_subscription_payment_orders.rb +53 -0
  50. data/examples/request_transaction_cancellation.rb +19 -0
  51. data/examples/split_payment/create_authorization.rb +32 -0
  52. data/examples/split_payment/create_payment_request.rb +71 -0
  53. data/examples/split_payment/create_transaction_using_boleto.rb +118 -0
  54. data/examples/split_payment/create_transaction_using_credit_card.rb +152 -0
  55. data/lib/pagseguro-oficial.rb +1 -0
  56. data/lib/pagseguro.rb +221 -0
  57. data/lib/pagseguro/account.rb +29 -0
  58. data/lib/pagseguro/account_credentials.rb +14 -0
  59. data/lib/pagseguro/address.rb +40 -0
  60. data/lib/pagseguro/application_credentials.rb +18 -0
  61. data/lib/pagseguro/authorization.rb +61 -0
  62. data/lib/pagseguro/authorization/collection.rb +28 -0
  63. data/lib/pagseguro/authorization/request_serializer.rb +24 -0
  64. data/lib/pagseguro/authorization/response.rb +49 -0
  65. data/lib/pagseguro/authorization/response_serializer.rb +40 -0
  66. data/lib/pagseguro/authorization_request.rb +84 -0
  67. data/lib/pagseguro/authorization_request/request_serializer.rb +142 -0
  68. data/lib/pagseguro/authorization_request/response.rb +26 -0
  69. data/lib/pagseguro/authorization_request/response_serializer.rb +18 -0
  70. data/lib/pagseguro/bank.rb +8 -0
  71. data/lib/pagseguro/boleto_transaction_request.rb +8 -0
  72. data/lib/pagseguro/company.rb +41 -0
  73. data/lib/pagseguro/config.rb +34 -0
  74. data/lib/pagseguro/credit_card_transaction_request.rb +39 -0
  75. data/lib/pagseguro/creditor_fee.rb +23 -0
  76. data/lib/pagseguro/document.rb +23 -0
  77. data/lib/pagseguro/documents.rb +5 -0
  78. data/lib/pagseguro/errors.rb +57 -0
  79. data/lib/pagseguro/exceptions.rb +3 -0
  80. data/lib/pagseguro/extensions/collection_object.rb +34 -0
  81. data/lib/pagseguro/extensions/credentiable.rb +17 -0
  82. data/lib/pagseguro/extensions/ensure_type.rb +9 -0
  83. data/lib/pagseguro/extensions/mass_assignment.rb +11 -0
  84. data/lib/pagseguro/holder.rb +36 -0
  85. data/lib/pagseguro/installment.rb +57 -0
  86. data/lib/pagseguro/installment/collection.rb +25 -0
  87. data/lib/pagseguro/installment/request_serializer.rb +24 -0
  88. data/lib/pagseguro/installment/response.rb +37 -0
  89. data/lib/pagseguro/installment/response_serializer.rb +22 -0
  90. data/lib/pagseguro/item.rb +34 -0
  91. data/lib/pagseguro/items.rb +23 -0
  92. data/lib/pagseguro/manual_subscription_charger.rb +59 -0
  93. data/lib/pagseguro/manual_subscription_charger/request_serializer.rb +50 -0
  94. data/lib/pagseguro/manual_subscription_charger/response.rb +36 -0
  95. data/lib/pagseguro/manual_subscription_charger/response_serializer.rb +17 -0
  96. data/lib/pagseguro/notification.rb +11 -0
  97. data/lib/pagseguro/notification/authorization.rb +15 -0
  98. data/lib/pagseguro/notification/transaction.rb +15 -0
  99. data/lib/pagseguro/online_debit_transaction_request.rb +17 -0
  100. data/lib/pagseguro/partner.rb +20 -0
  101. data/lib/pagseguro/payment_method.rb +39 -0
  102. data/lib/pagseguro/payment_release.rb +21 -0
  103. data/lib/pagseguro/payment_releases.rb +28 -0
  104. data/lib/pagseguro/payment_request.rb +117 -0
  105. data/lib/pagseguro/payment_request/request_serializer.rb +203 -0
  106. data/lib/pagseguro/payment_request/response.rb +35 -0
  107. data/lib/pagseguro/payment_status.rb +39 -0
  108. data/lib/pagseguro/permission.rb +13 -0
  109. data/lib/pagseguro/person.rb +40 -0
  110. data/lib/pagseguro/phone.rb +20 -0
  111. data/lib/pagseguro/phones.rb +5 -0
  112. data/lib/pagseguro/receiver.rb +20 -0
  113. data/lib/pagseguro/receiver_split.rb +15 -0
  114. data/lib/pagseguro/request.rb +170 -0
  115. data/lib/pagseguro/sender.rb +53 -0
  116. data/lib/pagseguro/session.rb +34 -0
  117. data/lib/pagseguro/session/response.rb +32 -0
  118. data/lib/pagseguro/session/response_serializer.rb +18 -0
  119. data/lib/pagseguro/shipping.rb +57 -0
  120. data/lib/pagseguro/subscription.rb +132 -0
  121. data/lib/pagseguro/subscription/request_serializer.rb +129 -0
  122. data/lib/pagseguro/subscription/response.rb +49 -0
  123. data/lib/pagseguro/subscription/response_serializer.rb +62 -0
  124. data/lib/pagseguro/subscription/subscription_search.rb +135 -0
  125. data/lib/pagseguro/subscription_canceller.rb +30 -0
  126. data/lib/pagseguro/subscription_canceller/response.rb +34 -0
  127. data/lib/pagseguro/subscription_change_payment.rb +46 -0
  128. data/lib/pagseguro/subscription_change_payment/request_serializer.rb +80 -0
  129. data/lib/pagseguro/subscription_change_payment/response.rb +26 -0
  130. data/lib/pagseguro/subscription_change_status.rb +50 -0
  131. data/lib/pagseguro/subscription_change_status/request_serializer.rb +28 -0
  132. data/lib/pagseguro/subscription_change_status/response.rb +26 -0
  133. data/lib/pagseguro/subscription_discount.rb +41 -0
  134. data/lib/pagseguro/subscription_discount/request_serializer.rb +34 -0
  135. data/lib/pagseguro/subscription_discount/response.rb +34 -0
  136. data/lib/pagseguro/subscription_payment_method.rb +21 -0
  137. data/lib/pagseguro/subscription_payment_order.rb +57 -0
  138. data/lib/pagseguro/subscription_payment_order/response.rb +37 -0
  139. data/lib/pagseguro/subscription_payment_order/response_serializer.rb +51 -0
  140. data/lib/pagseguro/subscription_plan.rb +69 -0
  141. data/lib/pagseguro/subscription_plan/request_serializer.rb +81 -0
  142. data/lib/pagseguro/subscription_plan/response.rb +36 -0
  143. data/lib/pagseguro/subscription_plan/response_serializer.rb +17 -0
  144. data/lib/pagseguro/subscription_retry.rb +35 -0
  145. data/lib/pagseguro/subscription_retry/response.rb +34 -0
  146. data/lib/pagseguro/subscription_search_payment_orders.rb +131 -0
  147. data/lib/pagseguro/subscription_transaction.rb +29 -0
  148. data/lib/pagseguro/subscription_transactions.rb +5 -0
  149. data/lib/pagseguro/transaction.rb +215 -0
  150. data/lib/pagseguro/transaction/collection.rb +20 -0
  151. data/lib/pagseguro/transaction/response.rb +45 -0
  152. data/lib/pagseguro/transaction/search.rb +121 -0
  153. data/lib/pagseguro/transaction/search/search_abandoned.rb +20 -0
  154. data/lib/pagseguro/transaction/search/search_by_date.rb +16 -0
  155. data/lib/pagseguro/transaction/search/search_by_reference.rb +13 -0
  156. data/lib/pagseguro/transaction/serializer.rb +181 -0
  157. data/lib/pagseguro/transaction_cancellation.rb +37 -0
  158. data/lib/pagseguro/transaction_cancellation/request_serializer.rb +18 -0
  159. data/lib/pagseguro/transaction_cancellation/response.rb +33 -0
  160. data/lib/pagseguro/transaction_cancellation/response_serializer.rb +17 -0
  161. data/lib/pagseguro/transaction_installment.rb +11 -0
  162. data/lib/pagseguro/transaction_refund.rb +44 -0
  163. data/lib/pagseguro/transaction_refund/request_serializer.rb +24 -0
  164. data/lib/pagseguro/transaction_refund/response.rb +33 -0
  165. data/lib/pagseguro/transaction_refund/response_serializer.rb +17 -0
  166. data/lib/pagseguro/transaction_request.rb +165 -0
  167. data/lib/pagseguro/transaction_request/request_serializer.rb +311 -0
  168. data/lib/pagseguro/transaction_request/response.rb +33 -0
  169. data/lib/pagseguro/transaction_request/response_serializer.rb +117 -0
  170. data/lib/pagseguro/transaction_status.rb +14 -0
  171. data/lib/pagseguro/version.rb +3 -0
  172. data/locales/pt-BR.yml +130 -0
  173. data/pagseguro-oficial.gemspec +31 -0
  174. data/spec/fixtures/authorization/find_authorization.xml +17 -0
  175. data/spec/fixtures/authorization/search_authorization.xml +47 -0
  176. data/spec/fixtures/authorization_request/authorization_request.xml +11 -0
  177. data/spec/fixtures/authorization_request/authorization_request_with_account.xml +47 -0
  178. data/spec/fixtures/authorization_request/success.xml +4 -0
  179. data/spec/fixtures/by_date/success.xml +85 -0
  180. data/spec/fixtures/installment/success.xml +24 -0
  181. data/spec/fixtures/invalid_code.xml +7 -0
  182. data/spec/fixtures/manual_subscription_charger/fail.xml +6 -0
  183. data/spec/fixtures/manual_subscription_charger/success.xml +4 -0
  184. data/spec/fixtures/payment_request/failure.xml +7 -0
  185. data/spec/fixtures/payment_request/success.xml +5 -0
  186. data/spec/fixtures/refund/success.xml +2 -0
  187. data/spec/fixtures/session/success.xml +4 -0
  188. data/spec/fixtures/subscription/fail.xml +6 -0
  189. data/spec/fixtures/subscription/find_success.xml +28 -0
  190. data/spec/fixtures/subscription/search_success.xml +18 -0
  191. data/spec/fixtures/subscription/success.xml +4 -0
  192. data/spec/fixtures/subscription_canceller/fail.xml +6 -0
  193. data/spec/fixtures/subscription_change_payment/fail.xml +7 -0
  194. data/spec/fixtures/subscription_change_status/fail.xml +7 -0
  195. data/spec/fixtures/subscription_discount/fail.xml +6 -0
  196. data/spec/fixtures/subscription_payment_order/success.xml +18 -0
  197. data/spec/fixtures/subscription_plan/fail.xml +6 -0
  198. data/spec/fixtures/subscription_plan/success.xml +4 -0
  199. data/spec/fixtures/subscription_retry/fail.xml +7 -0
  200. data/spec/fixtures/subscription_search_payment_orders/success.xml +43 -0
  201. data/spec/fixtures/transaction_cancellation/success.xml +2 -0
  202. data/spec/fixtures/transaction_request/success.xml +58 -0
  203. data/spec/fixtures/transactions/additional.xml +53 -0
  204. data/spec/fixtures/transactions/search.xml +40 -0
  205. data/spec/fixtures/transactions/success.xml +75 -0
  206. data/spec/fixtures/transactions/without_status_and_type.xml +71 -0
  207. data/spec/pagseguro/account_credentials_spec.rb +10 -0
  208. data/spec/pagseguro/account_spec.rb +27 -0
  209. data/spec/pagseguro/address_spec.rb +17 -0
  210. data/spec/pagseguro/application_credentials_spec.rb +11 -0
  211. data/spec/pagseguro/authorization/collection_spec.rb +49 -0
  212. data/spec/pagseguro/authorization/request_serializer_spec.rb +10 -0
  213. data/spec/pagseguro/authorization/response_serializer_spec.rb +19 -0
  214. data/spec/pagseguro/authorization/response_spec.rb +90 -0
  215. data/spec/pagseguro/authorization_request/request_serializer_spec.rb +323 -0
  216. data/spec/pagseguro/authorization_request/response_serializer_spec.rb +15 -0
  217. data/spec/pagseguro/authorization_request/response_spec.rb +36 -0
  218. data/spec/pagseguro/authorization_request_spec.rb +127 -0
  219. data/spec/pagseguro/authorization_spec.rb +111 -0
  220. data/spec/pagseguro/bank_spec.rb +5 -0
  221. data/spec/pagseguro/boleto_transaction_request_spec.rb +9 -0
  222. data/spec/pagseguro/company_spec.rb +12 -0
  223. data/spec/pagseguro/config_spec.rb +5 -0
  224. data/spec/pagseguro/credit_card_transaction_request_spec.rb +36 -0
  225. data/spec/pagseguro/creditor_fee_spec.rb +10 -0
  226. data/spec/pagseguro/document_spec.rb +21 -0
  227. data/spec/pagseguro/documents_spec.rb +37 -0
  228. data/spec/pagseguro/errors_spec.rb +145 -0
  229. data/spec/pagseguro/extensions/collection_object_spec.rb +77 -0
  230. data/spec/pagseguro/features/create_session_spec.rb +52 -0
  231. data/spec/pagseguro/features/create_transaction_request_spec.rb +58 -0
  232. data/spec/pagseguro/holder_spec.rb +10 -0
  233. data/spec/pagseguro/installment/collection_spec.rb +43 -0
  234. data/spec/pagseguro/installment/request_serializer_spec.rb +16 -0
  235. data/spec/pagseguro/installment/response_serializer_spec.rb +33 -0
  236. data/spec/pagseguro/installment/response_spec.rb +56 -0
  237. data/spec/pagseguro/installment_spec.rb +50 -0
  238. data/spec/pagseguro/item_spec.rb +20 -0
  239. data/spec/pagseguro/items_spec.rb +148 -0
  240. data/spec/pagseguro/manual_subscription_charger/request_serializer_spec.rb +79 -0
  241. data/spec/pagseguro/manual_subscription_charger/response_serializer_spec.rb +10 -0
  242. data/spec/pagseguro/manual_subscription_charger/response_spec.rb +65 -0
  243. data/spec/pagseguro/manual_subscription_charger_spec.rb +68 -0
  244. data/spec/pagseguro/notification_spec.rb +6 -0
  245. data/spec/pagseguro/online_debit_transaction_request_spec.rb +18 -0
  246. data/spec/pagseguro/pagseguro_spec.rb +82 -0
  247. data/spec/pagseguro/partner_spec.rb +8 -0
  248. data/spec/pagseguro/payment_method_spec.rb +42 -0
  249. data/spec/pagseguro/payment_release_spec.rb +9 -0
  250. data/spec/pagseguro/payment_releases_spec.rb +34 -0
  251. data/spec/pagseguro/payment_request/request_serializer_spec.rb +283 -0
  252. data/spec/pagseguro/payment_request/response_spec.rb +13 -0
  253. data/spec/pagseguro/payment_request_spec.rb +148 -0
  254. data/spec/pagseguro/payment_status_spec.rb +33 -0
  255. data/spec/pagseguro/permission_spec.rb +7 -0
  256. data/spec/pagseguro/person_spec.rb +10 -0
  257. data/spec/pagseguro/phone_spec.rb +6 -0
  258. data/spec/pagseguro/phones_spec.rb +38 -0
  259. data/spec/pagseguro/receiver_spec.rb +7 -0
  260. data/spec/pagseguro/receiver_split_spec.rb +7 -0
  261. data/spec/pagseguro/request_spec.rb +114 -0
  262. data/spec/pagseguro/sender_spec.rb +25 -0
  263. data/spec/pagseguro/session/response_serializer_spec.rb +12 -0
  264. data/spec/pagseguro/session/response_spec.rb +57 -0
  265. data/spec/pagseguro/session_spec.rb +45 -0
  266. data/spec/pagseguro/shipping_spec.rb +40 -0
  267. data/spec/pagseguro/subscription/request_serializer_spec.rb +233 -0
  268. data/spec/pagseguro/subscription/response_serializer_spec.rb +46 -0
  269. data/spec/pagseguro/subscription/response_spec.rb +79 -0
  270. data/spec/pagseguro/subscription/subscription_search_spec.rb +154 -0
  271. data/spec/pagseguro/subscription_canceller/response_spec.rb +58 -0
  272. data/spec/pagseguro/subscription_canceller_spec.rb +57 -0
  273. data/spec/pagseguro/subscription_change_payment/request_serializer_spec.rb +150 -0
  274. data/spec/pagseguro/subscription_change_payment/response_spec.rb +41 -0
  275. data/spec/pagseguro/subscription_change_payment_spec.rb +60 -0
  276. data/spec/pagseguro/subscription_change_status/request_serializer_spec.rb +19 -0
  277. data/spec/pagseguro/subscription_change_status/response_spec.rb +41 -0
  278. data/spec/pagseguro/subscription_change_status_spec.rb +53 -0
  279. data/spec/pagseguro/subscription_discount/request_serializer_spec.rb +27 -0
  280. data/spec/pagseguro/subscription_discount/response_spec.rb +58 -0
  281. data/spec/pagseguro/subscription_discount_spec.rb +60 -0
  282. data/spec/pagseguro/subscription_payment_method_spec.rb +10 -0
  283. data/spec/pagseguro/subscription_payment_order/response_serializer_spec.rb +24 -0
  284. data/spec/pagseguro/subscription_payment_order/response_spec.rb +55 -0
  285. data/spec/pagseguro/subscription_payment_order_spec.rb +27 -0
  286. data/spec/pagseguro/subscription_plan/request_serializer_spec.rb +253 -0
  287. data/spec/pagseguro/subscription_plan/response_serializer_spec.rb +10 -0
  288. data/spec/pagseguro/subscription_plan/response_spec.rb +65 -0
  289. data/spec/pagseguro/subscription_plan_spec.rb +118 -0
  290. data/spec/pagseguro/subscription_retry/response_spec.rb +58 -0
  291. data/spec/pagseguro/subscription_retry_spec.rb +62 -0
  292. data/spec/pagseguro/subscription_search_payment_order_spec.rb +129 -0
  293. data/spec/pagseguro/subscription_spec.rb +137 -0
  294. data/spec/pagseguro/subscription_transaction_spec.rb +24 -0
  295. data/spec/pagseguro/subscription_transactions_spec.rb +37 -0
  296. data/spec/pagseguro/transaction/collection_spec.rb +43 -0
  297. data/spec/pagseguro/transaction/response_spec.rb +60 -0
  298. data/spec/pagseguro/transaction/search/search_abandoned_spec.rb +55 -0
  299. data/spec/pagseguro/transaction/search/search_by_date_spec.rb +28 -0
  300. data/spec/pagseguro/transaction/search/search_by_reference_spec.rb +21 -0
  301. data/spec/pagseguro/transaction/search_spec.rb +133 -0
  302. data/spec/pagseguro/transaction/serializer_spec.rb +86 -0
  303. data/spec/pagseguro/transaction_cancellation/request_serializer_spec.rb +13 -0
  304. data/spec/pagseguro/transaction_cancellation/response_serializer_spec.rb +9 -0
  305. data/spec/pagseguro/transaction_cancellation/response_spec.rb +45 -0
  306. data/spec/pagseguro/transaction_cancellation_spec.rb +60 -0
  307. data/spec/pagseguro/transaction_installment_spec.rb +6 -0
  308. data/spec/pagseguro/transaction_refund/request_serializer_spec.rb +15 -0
  309. data/spec/pagseguro/transaction_refund/response_serializer_spec.rb +12 -0
  310. data/spec/pagseguro/transaction_refund/response_spec.rb +39 -0
  311. data/spec/pagseguro/transaction_refund_spec.rb +71 -0
  312. data/spec/pagseguro/transaction_request/request_serializer_spec.rb +677 -0
  313. data/spec/pagseguro/transaction_request/response_serializer_spec.rb +52 -0
  314. data/spec/pagseguro/transaction_request/response_spec.rb +63 -0
  315. data/spec/pagseguro/transaction_request_spec.rb +156 -0
  316. data/spec/pagseguro/transaction_spec.rb +265 -0
  317. data/spec/pagseguro/transaction_status_spec.rb +7 -0
  318. data/spec/spec_helper.rb +35 -0
  319. data/spec/support/ensure_type_macro.rb +35 -0
  320. data/spec/support/helpers.rb +14 -0
  321. data/spec/support/mass_assignment_macro.rb +11 -0
  322. data/spec/support/shared_examples_for_configuration.rb +10 -0
  323. data/transaction/transaction_refund.rb +25 -0
  324. metadata +641 -0
@@ -0,0 +1,40 @@
1
+ <transactionSearchResult>
2
+ <date>2011-02-16T20:14:35.000-02:00</date>
3
+ <currentPage>1</currentPage>
4
+ <resultsInThisPage>10</resultsInThisPage>
5
+ <totalPages>1</totalPages>
6
+ <transactions>
7
+ <transaction>
8
+ <date>2011-02-05T15:46:12.000-02:00</date>
9
+ <lastEventDate>2011-02-15T17:39:14.000-03:00</lastEventDate>
10
+ <code>9E884542-81B3-4419-9A75-BCC6FB495EF1</code>
11
+ <reference>REF1234</reference>
12
+ <type>1</type>
13
+ <status>3</status>
14
+ <paymentMethod>
15
+ <type>1</type>
16
+ </paymentMethod>
17
+ <grossAmount>49900.00</grossAmount>
18
+ <discountAmount>0.00</discountAmount>
19
+ <feeAmount>0.00</feeAmount>
20
+ <netAmount>49900.00</netAmount>
21
+ <extraAmount>0.00</extraAmount>
22
+ </transaction>
23
+ <transaction>
24
+ <date>2011-02-07T18:57:52.000-02:00</date>
25
+ <lastEventDate>2011-02-14T21:37:24.000-03:00</lastEventDate>
26
+ <code>2FB07A22-68FF-4F83-A356-24153A0C05E1</code>
27
+ <reference>REF5678</reference>
28
+ <type>3</type>
29
+ <status>4</status>
30
+ <paymentMethod>
31
+ <type>3</type>
32
+ </paymentMethod>
33
+ <grossAmount>26900.00</grossAmount>
34
+ <discountAmount>0.00</discountAmount>
35
+ <feeAmount>0.00</feeAmount>
36
+ <netAmount>26900.00</netAmount>
37
+ <extraAmount>0.00</extraAmount>
38
+ </transaction>
39
+ </transactions>
40
+ </transactionSearchResult>
@@ -0,0 +1,75 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
2
+ <transaction>
3
+ <date>2013-05-01T01:40:27.000-03:00</date>
4
+ <code>667A3914-4F9F-4705-0EB6-CA6FA0DF8A19</code>
5
+ <reference>REF1234</reference>
6
+ <type>1</type>
7
+ <status>1</status>
8
+ <lastEventDate>2013-05-01T01:41:20.000-03:00</lastEventDate>
9
+ <!-- <cancellationSource>PagSeguro</cancellationSource> -->
10
+ <!-- <escrowEndDate>2013-06-01T01:41:20.000-03:00</escrowEndDate> -->
11
+ <paymentMethod>
12
+ <type>2</type>
13
+ <code>202</code>
14
+ </paymentMethod>
15
+ <paymentLink>https://pagseguro.uol.com.br/checkout/imprimeBoleto.jhtml?code=667D39144F9F47059FB6CA6FA0DF8A20</paymentLink>
16
+ <grossAmount>459.50</grossAmount>
17
+ <discountAmount>0.00</discountAmount>
18
+ <creditorFees>
19
+ <operationalFeeAmount>0.00</operationalFeeAmount>
20
+ <installmentFeeAmount>0.00</installmentFeeAmount>
21
+ <intermediationRateAmount>0.40</intermediationRateAmount>
22
+ <intermediationFeeAmount>1644.80</intermediationFeeAmount>
23
+ <commissionFeeAmount>1.98</commissionFeeAmount>
24
+ <efrete>1.98</efrete>
25
+ </creditorFees>
26
+ <netAmount>445.77</netAmount>
27
+ <extraAmount>0.00</extraAmount>
28
+ <installmentCount>1</installmentCount>
29
+ <paymentReleases>
30
+ <paymentRelease>
31
+ <installment>1</installment>
32
+ <totalAmount>202.92</totalAmount>
33
+ <releaseAmount>202.92</releaseAmount>
34
+ <status>OPENED</status>
35
+ <releaseDate>2015-03-25T16:14:23-03:00</releaseDate>
36
+ </paymentRelease>
37
+ </paymentReleases>
38
+ <itemCount>1</itemCount>
39
+ <items>
40
+ <item>
41
+ <id>1234</id>
42
+ <description>Some product</description>
43
+ <quantity>1</quantity>
44
+ <amount>459.50</amount>
45
+ </item>
46
+ </items>
47
+ <sender>
48
+ <name>JOHN DOE</name>
49
+ <email>john@example.com</email>
50
+ <phone>
51
+ <areaCode>11</areaCode>
52
+ <number>12345678</number>
53
+ </phone>
54
+ <documents>
55
+ <document>
56
+ <type>CPF</type>
57
+ <value>65647162142</value>
58
+ </document>
59
+ </documents>
60
+ </sender>
61
+ <shipping>
62
+ <address>
63
+ <street>AV. BRIG. FARIA LIMA</street>
64
+ <number>1384</number>
65
+ <complement>5 ANDAR</complement>
66
+ <district>JARDIM PAULISTANO</district>
67
+ <postalCode>01452002</postalCode>
68
+ <city>SAO PAULO</city>
69
+ <state>SP</state>
70
+ <country>BRA</country>
71
+ </address>
72
+ <type>2</type>
73
+ <cost>0.00</cost>
74
+ </shipping>
75
+ </transaction>
@@ -0,0 +1,71 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
2
+ <transaction>
3
+ <date>2013-05-01T01:40:27.000-03:00</date>
4
+ <code>667A3914-4F9F-4705-0EB6-CA6FA0DF8A19</code>
5
+ <reference>REF1234</reference>
6
+ <lastEventDate>2013-05-01T01:41:20.000-03:00</lastEventDate>
7
+ <paymentMethod>
8
+ <type>2</type>
9
+ <code>202</code>
10
+ </paymentMethod>
11
+ <paymentLink>https://pagseguro.uol.com.br/checkout/imprimeBoleto.jhtml?code=667D39144F9F47059FB6CA6FA0DF8A20</paymentLink>
12
+ <grossAmount>459.50</grossAmount>
13
+ <discountAmount>0.00</discountAmount>
14
+ <creditorFees>
15
+ <operationalFeeAmount>0.00</operationalFeeAmount>
16
+ <installmentFeeAmount>0.00</installmentFeeAmount>
17
+ <intermediationRateAmount>0.40</intermediationRateAmount>
18
+ <intermediationFeeAmount>1644.80</intermediationFeeAmount>
19
+ <commissionFeeAmount>1.98</commissionFeeAmount>
20
+ <efrete>1.98</efrete>
21
+ </creditorFees>
22
+ <netAmount>445.77</netAmount>
23
+ <extraAmount>0.00</extraAmount>
24
+ <installmentCount>1</installmentCount>
25
+ <paymentReleases>
26
+ <paymentRelease>
27
+ <installment>1</installment>
28
+ <totalAmount>202.92</totalAmount>
29
+ <releaseAmount>202.92</releaseAmount>
30
+ <status>OPENED</status>
31
+ <releaseDate>2015-03-25T16:14:23-03:00</releaseDate>
32
+ </paymentRelease>
33
+ </paymentReleases>
34
+ <itemCount>1</itemCount>
35
+ <items>
36
+ <item>
37
+ <id>1234</id>
38
+ <description>Some product</description>
39
+ <quantity>1</quantity>
40
+ <amount>459.50</amount>
41
+ </item>
42
+ </items>
43
+ <sender>
44
+ <name>JOHN DOE</name>
45
+ <email>john@example.com</email>
46
+ <phone>
47
+ <areaCode>11</areaCode>
48
+ <number>12345678</number>
49
+ </phone>
50
+ <documents>
51
+ <document>
52
+ <type>CPF</type>
53
+ <value>65647162142</value>
54
+ </document>
55
+ </documents>
56
+ </sender>
57
+ <shipping>
58
+ <address>
59
+ <street>AV. BRIG. FARIA LIMA</street>
60
+ <number>1384</number>
61
+ <complement>5 ANDAR</complement>
62
+ <district>JARDIM PAULISTANO</district>
63
+ <postalCode>01452002</postalCode>
64
+ <city>SAO PAULO</city>
65
+ <state>SP</state>
66
+ <country>BRA</country>
67
+ </address>
68
+ <type>2</type>
69
+ <cost>0.00</cost>
70
+ </shipping>
71
+ </transaction>
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::AccountCredentials do
4
+ describe 'credentials attributes' do
5
+ credentials = PagSeguro::AccountCredentials.new('foo@bar.com', 'token')
6
+
7
+ it { expect(credentials.email).to eq('foo@bar.com') }
8
+ it { expect(credentials.token).to eq('token') }
9
+ end
10
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe PagSeguro::Account do
4
+ it_assigns_attribute :email
5
+ it_assigns_attribute :type
6
+
7
+ it_ensures_type PagSeguro::Company, :company
8
+ it_ensures_type PagSeguro::Person, :person
9
+
10
+ context 'only person or company should be assigned' do
11
+ it "with company assigned, person can't be assigned too" do
12
+ subject.company = PagSeguro::Company.new
13
+ subject.person = PagSeguro::Person.new
14
+
15
+ expect(subject.company).to be_a PagSeguro::Company
16
+ expect(subject.person).to be_nil
17
+ end
18
+
19
+ it "with person assigned, company can't be assigned too" do
20
+ subject.person = PagSeguro::Person.new
21
+ subject.company = PagSeguro::Company.new
22
+
23
+ expect(subject.person).to be_a PagSeguro::Person
24
+ expect(subject.company).to be_nil
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::Address do
4
+ it_assigns_attribute :street
5
+ it_assigns_attribute :number
6
+ it_assigns_attribute :complement
7
+ it_assigns_attribute :district
8
+ it_assigns_attribute :city
9
+ it_assigns_attribute :state
10
+ it_assigns_attribute :country
11
+ it_assigns_attribute :postal_code
12
+
13
+ it "sets default country" do
14
+ address = PagSeguro::Address.new
15
+ expect(address.country).to eql("BRA")
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::ApplicationCredentials do
4
+ describe 'credentials attributes' do
5
+ credentials = PagSeguro::ApplicationCredentials.new('app123', 'qwerty')
6
+
7
+ it { expect(credentials.app_id).to eq('app123') }
8
+ it { expect(credentials.app_key).to eq('qwerty') }
9
+ it { expect(credentials.authorization_code).to be_nil }
10
+ end
11
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::Authorization::Collection do
4
+ let(:permission) { double(:permission) }
5
+ let(:authorizations) do
6
+ [
7
+ { code: '1234', created_at: Date.today, permissions: [permission] },
8
+ { code: '4321', created_at: Date.today, permissions: [permission, permission] }
9
+ ]
10
+ end
11
+ subject { described_class.new({authorizations: authorizations}) }
12
+
13
+ describe "initialization" do
14
+ context "when options[:errors] is present" do
15
+ let(:errors) { double(:errors) }
16
+ subject { described_class.new({errors: errors}) }
17
+
18
+ it "sets errors" do
19
+ expect(subject.errors).to eq(errors)
20
+ end
21
+
22
+ it "has no authorizations" do
23
+ expect(subject).to be_empty
24
+ end
25
+ end
26
+
27
+ context "when options[:authorizations] is present" do
28
+ it { expect(subject).to be_any }
29
+ it { expect(subject).not_to be_empty }
30
+
31
+ it "has authorizations instances" do
32
+ subject.each do |installment|
33
+ expect(installment).to be_a(PagSeguro::Authorization)
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "#errors" do
40
+ it { expect(subject.errors).to be_a(PagSeguro::Errors) }
41
+ it { expect(subject.errors).to be_empty }
42
+ end
43
+
44
+ describe "method delegation" do
45
+ it { is_expected.to respond_to(:each) }
46
+ it { is_expected.to respond_to(:empty?) }
47
+ it { is_expected.to respond_to(:any?) }
48
+ end
49
+ end
@@ -0,0 +1,10 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::Authorization::RequestSerializer do
4
+ let(:credentials) { PagSeguro::ApplicationCredentials.new('app11', 'sada') }
5
+ let(:options) { { credentials: credentials } }
6
+ let(:serializer) { described_class.new(options) }
7
+ let(:params) { serializer.to_params }
8
+
9
+ it{ expect(params).to include(credentials: credentials) }
10
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::Authorization::ResponseSerializer do
4
+ context "when payment request is created" do
5
+ let(:source) { File.read("./spec/fixtures/authorization/find_authorization.xml") }
6
+ let(:xml) { Nokogiri::XML(source) }
7
+ let(:serializer) { described_class.new(xml.css("authorization").first) }
8
+
9
+ subject(:data) { serializer.serialize }
10
+
11
+ it { expect(data[:code]).to eql("9D7FF2E921216F1334EE9FBEB7B4EBBC") }
12
+ it { expect(data[:created_at]).to eql(Time.parse("2011-03-30T14:20:13.000-03:00")) }
13
+ it { expect(data[:reference]).to eql("ref1234") }
14
+ it { expect(data[:permissions]).to be_a(Array) }
15
+ it { expect(data[:permissions].first.code).to eq("CREATE_CHECKOUTS") }
16
+ it { expect(data[:permissions].first.status).to eq("APPROVED") }
17
+ end
18
+ end
19
+
@@ -0,0 +1,90 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::Authorization::Response do
4
+ subject { described_class.new(response, object) }
5
+
6
+ describe "#serialize_collection" do
7
+ let(:xml) { File.read("./spec/fixtures/authorization/search_authorization.xml") }
8
+ let(:object) { PagSeguro::Authorization::Collection.new }
9
+ let(:response) do
10
+ double(
11
+ :Response,
12
+ body: xml,
13
+ code: 200,
14
+ success?: true,
15
+ xml?: true
16
+ )
17
+ end
18
+
19
+ context "when request succeeds" do
20
+ it "does not return a empty collection" do
21
+ expect { subject.serialize_collection }.not_to change { object.errors.empty? }
22
+ end
23
+
24
+ it "must have only PagSeguro::Authorization" do
25
+ subject.serialize_collection
26
+
27
+ object.each do |authorization|
28
+ expect(authorization).to be_a_kind_of PagSeguro::Authorization
29
+ end
30
+ end
31
+ end
32
+
33
+ context "when request fails" do
34
+ let(:response) do
35
+ double(
36
+ :Response,
37
+ body: xml,
38
+ code: 403,
39
+ xml?: true,
40
+ success?: false,
41
+ error?: true,
42
+ error: Aitch::ForbiddenError
43
+ )
44
+ end
45
+
46
+ it "serialize errors" do
47
+ expect { subject.serialize_collection }.to change { object.errors.empty? }
48
+ end
49
+ end
50
+ end
51
+
52
+ describe "#serialize" do
53
+ let(:xml) { File.read("./spec/fixtures/authorization/find_authorization.xml") }
54
+ let(:object) { PagSeguro::Authorization.new }
55
+
56
+ context "when request succeeds" do
57
+ let(:response) do
58
+ double(
59
+ :Response,
60
+ body: xml,
61
+ code: 200,
62
+ xml?: true,
63
+ success?: true,
64
+ )
65
+ end
66
+
67
+ it "returns a hash with serialized response data" do
68
+ expect { subject.serialize }.to change { object.code }.to('9D7FF2E921216F1334EE9FBEB7B4EBBC')
69
+ end
70
+ end
71
+
72
+ context "when request fails" do
73
+ let(:response) do
74
+ double(
75
+ :Response,
76
+ body: xml,
77
+ code: 404,
78
+ xml?: true,
79
+ success?: false,
80
+ error?: true,
81
+ error: Aitch::NotFoundError
82
+ )
83
+ end
84
+
85
+ it "serialize errors" do
86
+ expect { subject.serialize }.to change { object.errors.empty? }
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,323 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples 'when address is assigned' do
4
+ it 'can have a postal code' do
5
+ address[:postal_code] = '01452002'
6
+
7
+ postal_code_parsed = node.at_css('> postalCode').text
8
+ expect(postal_code_parsed).to eq '01452002'
9
+ end
10
+
11
+ it 'can have a street' do
12
+ address[:street] = 'Av. Brig. Faria Lima'
13
+
14
+ street_parsed = node.at_css('> street').text
15
+ expect(street_parsed).to eq 'Av. Brig. Faria Lima'
16
+ end
17
+
18
+ it 'can have a number' do
19
+ address[:number] = '1384'
20
+
21
+ number_parsed = node.at_css('> number').text
22
+ expect(number_parsed).to eq '1384'
23
+ end
24
+
25
+ it 'can have a complement' do
26
+ address[:complement] = '5o andar'
27
+
28
+ complement_parsed = node.at_css('> complement').text
29
+ expect(complement_parsed).to eq '5o andar'
30
+ end
31
+
32
+ it 'can have a district' do
33
+ address[:district] = 'Jardim Paulistano'
34
+
35
+ district_parsed = node.at_css('> district').text
36
+ expect(district_parsed).to eq 'Jardim Paulistano'
37
+ end
38
+
39
+ it 'can have a city' do
40
+ address[:city] = 'Sao Paulo'
41
+
42
+ city_parsed = node.at_css('> city').text
43
+ expect(city_parsed).to eq 'Sao Paulo'
44
+ end
45
+
46
+ it 'can have a state' do
47
+ address[:state] = 'SP'
48
+
49
+ state_parsed = node.at_css('> state').text
50
+ expect(state_parsed).to eq 'SP'
51
+ end
52
+
53
+ it 'can have a country' do
54
+ address[:country] = 'BRA'
55
+
56
+ country_parsed = node.at_css('> country').text
57
+ expect(country_parsed).to eq 'BRA'
58
+ end
59
+ end
60
+
61
+ shared_examples 'when documents is assigned' do
62
+ context 'when one document is given' do
63
+ before do
64
+ documents << { type: 'CPF', value: '99988877766' }
65
+ end
66
+
67
+ let(:documents_parsed) { node.css('> document') }
68
+
69
+ it 'must have the correct type' do
70
+ expect( documents_parsed.at_css('> type').text ).to eq 'CPF'
71
+ end
72
+
73
+ it 'must have the correct value' do
74
+ expect( documents_parsed.at_css('> value').text ).to eq '99988877766'
75
+ end
76
+ end
77
+
78
+ context 'when multiple documents is given' do
79
+ before do
80
+ documents << { type: 'CPF', value: '99988877766' }
81
+ documents << { type: 'CNPJ', value: '17302417000101' }
82
+ end
83
+
84
+ let(:documents_parsed) do
85
+ node.css('> document').map do |node|
86
+ {
87
+ type: node.at_css('> type').text,
88
+ value: node.at_css('> value').text
89
+ }
90
+ end
91
+ end
92
+
93
+ it 'must have the correct number of documents' do
94
+ expect(documents_parsed.size).to eq 2
95
+ end
96
+
97
+ it 'must have the correct documents' do
98
+ expect(documents_parsed).to contain_exactly(
99
+ { type: 'CPF', value: '99988877766' },
100
+ { type: 'CNPJ', value: '17302417000101' }
101
+ )
102
+ end
103
+ end
104
+ end
105
+
106
+ shared_examples 'when phones is assigned' do
107
+ context 'when one phone is given' do
108
+ before do
109
+ phones << { type: 'HOME', area_code: '11', number: '30302323' }
110
+ end
111
+
112
+ let(:phone_parsed) { node.at_css('> phone') }
113
+
114
+ it 'must have a type' do
115
+ expect( phone_parsed.at_css('> type').text ).to eq 'HOME'
116
+ end
117
+
118
+ it 'must have an area code' do
119
+ expect( phone_parsed.at_css('> areaCode').text ).to eq '11'
120
+ end
121
+
122
+ it 'must have a number' do
123
+ expect( phone_parsed.at_css('> number').text ).to eq '30302323'
124
+ end
125
+ end
126
+
127
+ context 'can have multiple phones' do
128
+ before do
129
+ phones << { type: 'HOME', area_code: '11', number: '30302323' }
130
+ phones << { type: 'MOBILE', area_code: '11', number: '976302323' }
131
+ end
132
+
133
+ let(:phones_parsed) do
134
+ node.css('> phone').map do |phone|
135
+ {
136
+ type: phone.at_css('> type').text,
137
+ area_code: phone.at_css('> areaCode').text,
138
+ number: phone.at_css('> number').text
139
+ }
140
+ end
141
+ end
142
+
143
+ it 'must have the correct number of phones' do
144
+ expect(phones_parsed.size).to eq 2
145
+ end
146
+
147
+ it 'must have the correct phones' do
148
+ expect(phones_parsed).to contain_exactly(
149
+ { type: 'HOME', area_code: '11', number: '30302323' },
150
+ { type: 'MOBILE', area_code: '11', number: '976302323' }
151
+ )
152
+ end
153
+ end
154
+ end
155
+
156
+ describe PagSeguro::AuthorizationRequest::RequestSerializer do
157
+ let(:credentials) { PagSeguro::ApplicationCredentials.new('app123', 'key123') }
158
+ let(:options) do
159
+ {
160
+ credentials: credentials,
161
+ permissions: [:checkouts, :searches, :notifications],
162
+ notification_url: 'http://seusite.com.br/redirect',
163
+ redirect_url: 'http://seusite.com.br/notification'
164
+ }
165
+ end
166
+
167
+ let(:authorization_request) { PagSeguro::AuthorizationRequest.new(options) }
168
+ let(:serializer) { described_class.new(authorization_request) }
169
+ let(:xml) { serializer.build_xml }
170
+ let(:xml_parsed) { Nokogiri::XML(xml) }
171
+ let(:node) { xml_parsed.at_css('authorizationRequest') }
172
+
173
+ it 'encoding should be equal to application encoding' do
174
+ encoding = xml_parsed.encoding
175
+ expect(encoding).to eq PagSeguro.encoding
176
+ end
177
+
178
+ it 'must have a authorizationRequest' do
179
+ expect(node).to be_a_instance_of Nokogiri::XML::Element
180
+ end
181
+
182
+ it 'must have the correct permissions' do
183
+ permissions = options[:permissions].map{|value| PagSeguro::AuthorizationRequest::PERMISSIONS[value] }
184
+ permissions_code_parsed = xml_parsed.css('authorizationRequest > permissions > code').map(&:text)
185
+
186
+ expect(permissions).to eq permissions_code_parsed
187
+ end
188
+
189
+ it 'must have a redirect URL' do
190
+ redirect_url_parsed = xml_parsed.at_css('authorizationRequest > redirectURL').text
191
+ expect(redirect_url_parsed).to eq options[:redirect_url]
192
+ end
193
+
194
+ it 'must have a notification URL' do
195
+ notification_url = xml_parsed.at_css('authorizationRequest > notificationURL').text
196
+ expect(notification_url).to eq options[:notification_url]
197
+ end
198
+
199
+ context 'when an account is assigned' do
200
+ let(:account) { {} }
201
+ let(:options) { super().merge(account: account) }
202
+ let(:node) { super().at_css('> account') }
203
+
204
+ it 'can have an email' do
205
+ account[:email] = 'usuario@seusite.com.br'
206
+ expect( node.at_css('> email').text ).to eq 'usuario@seusite.com.br'
207
+ end
208
+
209
+ it 'can have a type' do
210
+ account[:type] = 'SELLER'
211
+ expect( node.at_css('> type').text ).to eq 'SELLER'
212
+ end
213
+
214
+ context 'when a person is assigned' do
215
+ let(:person) { {} }
216
+ let(:account) { super().merge(person: person) }
217
+ let(:node) { super().at_css('> person') }
218
+
219
+ it 'can have name' do
220
+ person[:name] = 'Antonio Carlos'
221
+ expect( node.at_css('> name').text ).to eq 'Antonio Carlos'
222
+ end
223
+
224
+ it 'can have birth date' do
225
+ person[:birth_date] = Date.new(1982, 2, 5)
226
+ expect( node.at_css('> birthDate').text ).to eq '1982-02-05'
227
+ end
228
+
229
+ context 'when the address is assigned' do
230
+ let(:address) { {} }
231
+ let(:person) { super().merge(address: address) }
232
+ let(:node) { super().at_css('> address') }
233
+
234
+ include_examples 'when address is assigned'
235
+ end
236
+
237
+ context 'when the documents is assigned' do
238
+ let(:documents) { [] }
239
+ let(:person) { super().merge({ documents: documents }) }
240
+ let(:node) { super().at_css('> documents') }
241
+
242
+ include_examples 'when documents is assigned'
243
+ end
244
+
245
+ context 'when the phones' do
246
+ let(:phones) { [] }
247
+ let(:person) { super().merge({ phones: phones }) }
248
+ let(:node) { super().at_css('> phones') }
249
+
250
+ include_examples 'when phones is assigned'
251
+ end
252
+ end
253
+
254
+ context 'when the company is assigned' do
255
+ let(:company) { {} }
256
+ let(:account) { super().merge({ company: company }) }
257
+ let(:node) { super().at_css('> company') }
258
+
259
+ it 'can have a name' do
260
+ company[:name] = 'Seu Site'
261
+ expect( node.at_css('> name').text ).to eq 'Seu Site'
262
+ end
263
+
264
+ it 'can have a display name' do
265
+ company[:display_name] = 'Seu Site'
266
+ expect( node.at_css('> displayName').text ).to eq 'Seu Site'
267
+ end
268
+
269
+ it 'can have a website url' do
270
+ company[:website_url] = 'http://www.seusite.com.br'
271
+ expect( node.at_css('> websiteURL').text ).to eq 'http://www.seusite.com.br'
272
+ end
273
+
274
+ context 'when the address is assigned' do
275
+ let(:address) { {} }
276
+ let(:company) { super().merge(address: address) }
277
+ let(:node) { super().at_css('> address') }
278
+
279
+ include_examples 'when address is assigned'
280
+ end
281
+
282
+ context 'when the documents is assigned' do
283
+ let(:documents) { [] }
284
+ let(:company) { super().merge({ documents: documents }) }
285
+ let(:node) { super().at_css('> documents') }
286
+
287
+ include_examples 'when documents is assigned'
288
+ end
289
+
290
+ context 'when the phones is assigned' do
291
+ let(:phones) { [] }
292
+ let(:company) { super().merge({ phones: phones }) }
293
+ let(:node) { super().at_css('> phones') }
294
+
295
+ include_examples 'when phones is assigned'
296
+ end
297
+
298
+ context 'when the partner is assigned' do
299
+ let(:partner) { {} }
300
+ let(:company) { super().merge({ partner: partner }) }
301
+ let(:node) { super().at_css('> partner') }
302
+
303
+ it 'can have a name' do
304
+ partner[:name] = 'Antonio Carlos'
305
+ expect( node.at_css('> name').text ).to eq 'Antonio Carlos'
306
+ end
307
+
308
+ it 'can have a birth date' do
309
+ partner[:birth_date] = Date.new(1982, 2, 5)
310
+ expect( node.at_css('> birthDate').text ).to eq '1982-02-05'
311
+ end
312
+
313
+ context 'when the documents is assigned' do
314
+ let(:documents) { [] }
315
+ let(:partner) { super().merge({ documents: documents }) }
316
+ let(:node) { super().at_css('> documents') }
317
+
318
+ include_examples 'when documents is assigned'
319
+ end
320
+ end
321
+ end
322
+ end
323
+ end