basecomm_sdk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +94 -0
  5. data/CHANGELOG +3 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +26 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +102 -0
  10. data/Rakefile +14 -0
  11. data/basecomm_sdk.gemspec +40 -0
  12. data/lib/basecomm_sdk/address.rb +25 -0
  13. data/lib/basecomm_sdk/bank_account.rb +29 -0
  14. data/lib/basecomm_sdk/bank_account_transaction.rb +48 -0
  15. data/lib/basecomm_sdk/bank_card.rb +26 -0
  16. data/lib/basecomm_sdk/bank_card_transaction.rb +52 -0
  17. data/lib/basecomm_sdk/base.rb +91 -0
  18. data/lib/basecomm_sdk/client.rb +151 -0
  19. data/lib/basecomm_sdk/push_notification.rb +22 -0
  20. data/lib/basecomm_sdk/settlement_batch.rb +18 -0
  21. data/lib/basecomm_sdk/triple_des_service.rb +36 -0
  22. data/lib/basecomm_sdk/version.rb +3 -0
  23. data/lib/basecomm_sdk.rb +31 -0
  24. data/spec/cassettes/BasecommSdk_Client/_add_bank_account/fails_when_passing_an_invalid_bank_account.yml +34 -0
  25. data/spec/cassettes/BasecommSdk_Client/_add_bank_account/returns_the_new_bank_account_instance.yml +34 -0
  26. data/spec/cassettes/BasecommSdk_Client/_add_bank_card/fails_when_passing_an_invalid_bank_card.yml +34 -0
  27. data/spec/cassettes/BasecommSdk_Client/_add_bank_card/returns_a_valid_new_bank_card_instance.yml +34 -0
  28. data/spec/cassettes/BasecommSdk_Client/_get_bank_account_transaction/fails_when_passing_invalid_bat_transaction.yml +34 -0
  29. data/spec/cassettes/BasecommSdk_Client/_get_bank_account_transaction/fails_when_passing_invalid_transaction.yml +34 -0
  30. data/spec/cassettes/BasecommSdk_Client/_get_bank_account_transaction/returns_the_specified_bank_account_transaction.yml +34 -0
  31. data/spec/cassettes/BasecommSdk_Client/_get_bank_card_transaction/collects_proper_responses_for_missing_transactions.yml +34 -0
  32. data/spec/cassettes/BasecommSdk_Client/_get_bank_card_transaction/returns_the_specified_bank_card_transaction.yml +34 -0
  33. data/spec/cassettes/BasecommSdk_Client/_process_bank_account_transaction/fails_when_passing_invalid_transaction.yml +34 -0
  34. data/spec/cassettes/BasecommSdk_Client/_process_bank_account_transaction/populates_messages_with_failure_reasons.yml +34 -0
  35. data/spec/cassettes/BasecommSdk_Client/_process_bank_account_transaction/returns_the_processed_bank_account_transaction.yml +34 -0
  36. data/spec/cassettes/BasecommSdk_Client/_process_bank_card_transaction/returns_the_processed_bank_account_transaction_for_auth.yml +34 -0
  37. data/spec/factories.rb +95 -0
  38. data/spec/lib/basecomm_sdk/address_spec.rb +53 -0
  39. data/spec/lib/basecomm_sdk/bank_account_spec.rb +53 -0
  40. data/spec/lib/basecomm_sdk/bank_account_transaction_spec.rb +60 -0
  41. data/spec/lib/basecomm_sdk/bank_card_spec.rb +55 -0
  42. data/spec/lib/basecomm_sdk/bank_card_transaction_spec.rb +55 -0
  43. data/spec/lib/basecomm_sdk/base_spec.rb +7 -0
  44. data/spec/lib/basecomm_sdk/client_spec.rb +204 -0
  45. data/spec/lib/basecomm_sdk/push_notification_spec.rb +14 -0
  46. data/spec/lib/basecomm_sdk/settlement_batch_spec.rb +14 -0
  47. data/spec/lib/basecomm_sdk/triple_des_service_spec.rb +39 -0
  48. data/spec/lib/basecomm_sdk_spec.rb +17 -0
  49. data/spec/spec_helper.rb +56 -0
  50. data/spec/support/shared_class_with_messages.rb +7 -0
  51. metadata +374 -0
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.basecommercesandbox.com/pcms/?f=API_processBankAccountTransactionV4
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"gateway_username":"simplefinance1","gateway_password":"brxEY5SxdMjG","payload":"dcd2610ecb6336d5f7f8842ebf6ce01b2d54b8865ecd0b3422a7de029ddbb81c96f9adf09e0bc8496c812edee9cf64d7bb19597eb2fcfc5cb3b8b78c95cc7c955e42cefc90140b8e6cb630e5986662208f00758ea9fdfd2b5ec9b30d35e1216136a2e06bfb79f623bcee41ca8ec8807a50c00d49eafa3e318167688c7267654dc904f2de88a243f90c89c83f147989512f9a4d8451eef9e6bf6154b340a2e6d8bc041c007f3ca9d7f7f8842ebf6ce01b2d54b8865ecd0b34d2970adb8d31234fd6e5368cdf2ddf8ef033db82d4260fb250c00d49eafa3e318167688c7267654d870126b3670a3cc3d0107f33c7a2f5a9bb89321629fec05d460fd73bb7c2b0fb6812f61992c3d6f8184cc25396c7f69e"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: ''
20
+ headers:
21
+ Date:
22
+ - Mon, 22 Dec 2014 18:30:36 GMT
23
+ Server:
24
+ - Apache/2.4.10 (FreeBSD) OpenSSL/1.0.1j
25
+ Set-Cookie:
26
+ - JSESSIONID=DAAF6AFB7BFC1EF34573F7B6F7C86D4B; Path=/; Secure
27
+ Content-Type:
28
+ - application/json
29
+ body:
30
+ encoding: UTF-8
31
+ string: 2D8674762DD0A47D9E3F44DC9DF2195F88FB1409340D7AB9A249EAA2FA0100CB2BF07A76743E9EEB0AB5FF6085F30E83A3C9C26A697D91D42D54B8865ECD0B342A26303984B1E32DBC041C007F3CA9D7F7F8842EBF6CE01B2D54B8865ECD0B347F885C8DE65531D3D40AFCCB8DAFD360FE87722D051072ADFA062FAAF28242E88098AC34DF2FD0E7997B8362AA473FFF5425FB12885FE781751BA5FC6B732B9121E73537F1F719D05E6E9DFA49815217B3114364255033CA997B8362AA473FFF1F72A5209E2FC2DB9C6A69E9509FF778D4C6BA07558CBE45B3B8B78C95CC7C955E42CEFC90140B8E4AB4452D22BDD713F51173E6E3CDB7F6F33308B59BF4156D8BA8A0E3F6B9CFAD6CAE6602D7A6FB2028B24F1673A5A5BAF7F8842EBF6CE01B79388FCAC453018A64A8C294F95DCB062E36634838E8B42945305E3741E23065E723E238BE497CFAB3B8B78C95CC7C955E42CEFC90140B8E4AB4452D22BDD713F51173E6E3CDB7F65F1B46C6C1990DF76C812EDEE9CF64D73DE99C565B263B408BA8A0E3F6B9CFAD6CAE6602D7A6FB200C5DCA152E725ADCFCEDDB9BD51BEA6D997B8362AA473FFF1F72A5209E2FC2DB9C6A69E9509FF7782247FB6EE18C7705F3F34B60BF9D693B982E3C6F8238C89E2D54B8865ECD0B347E41A80F6B02CC33C76DAAFA544583262D3F8FC47EE08EBA7C6EE8935EA67DB44C63F27BFD73CBA0CEBDCB1FDFF27E2088D2BD4F01DB676CA54D96B45937E84BB3B8B78C95CC7C955E42CEFC90140B8E6CB630E5986662208F00758EA9FDFD2B5EC9B30D35E1216136A2E06BFB79F62380BBBC66A5D0DBA2E2839B4B09861E41FAF90FFF70AB702703AA68BF5714EFCDBC041C007F3CA9D7F7F8842EBF6CE01B2D54B8865ECD0B3422A7DE029DDBB81CDD06EBE87B6D27E4FD1F4CDAADDA40023D2386C63CCD5F51997B8362AA473FFF1F72A5209E2FC2DB9C6A69E9509FF7780741949DE029E33C1EFC607450A75AA0BC041C007F3CA9D7F7F8842EBF6CE01B2D54B8865ECD0B34218EF0C0B3C5FC6F35DF65DD02F75E882BF07A76743E9EEB6F10D99B010BE0C7CF9BB41DAD557A41ABB86E534CC507D9997B8362AA473FFF1F72A5209E2FC2DB9C6A69E9509FF7783FD78DDD121BE951877FCC87392E790FB660A8F0A5DAB7311953E061E8F84DAB3A4A216F040A3D3F73B18D33B35D0534
32
+ http_version:
33
+ recorded_at: Mon, 22 Dec 2014 18:30:03 GMT
34
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.basecommercesandbox.com/pcms/?f=API_processBankAccountTransactionV4
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"gateway_username":"simplefinance1","gateway_password":"brxEY5SxdMjG","payload":"dcd2610ecb6336d5f7f8842ebf6ce01b2d54b8865ecd0b347f994197c62fbb32a5e13bb954537a18bc041c007f3ca9d7f7f8842ebf6ce01b2d54b8865ecd0b347f885c8de65531d3aef446f0f54c96b7bc041c007f3ca9d7f7f8842ebf6ce01b2d54b8865ecd0b3422a7de029ddbb81c96f9adf09e0bc8496c812edee9cf64d7bb19597eb2fcfc5cb3b8b78c95cc7c955e42cefc90140b8e6cb630e5986662208f00758ea9fdfd2b5ec9b30d35e1216136a2e06bfb79f623bcee41ca8ec8807a50c00d49eafa3e318167688c7267654dc904f2de88a243f9699e5a1b4104e56a809617099ea65952a18f9402f5018d17aceedd396c0dd56d2d3f8fc47ee08eba7c6ee8935ea67db4ae2dd9f8c9a8be99e8b3e4eee9a1119fac4a84021ededb3f50047da0bc65f6dfbcee41ca8ec8807a50c00d49eafa3e318167688c7267654d0e0bc18e6f760475eb9b73016e706ec9660b002655e5969250c00d49eafa3e318167688c7267654d870126b3670a3cc3d0107f33c7a2f5a9bb89321629fec05da2c0831c69be688b5130785885c79020184cc25396c7f69e"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: ''
20
+ headers:
21
+ Date:
22
+ - Fri, 19 Dec 2014 23:15:46 GMT
23
+ Server:
24
+ - Apache/2.4.10 (FreeBSD) OpenSSL/1.0.1j
25
+ Set-Cookie:
26
+ - JSESSIONID=773BEBDA6BAEF220062E0158813E9FD0; Path=/; Secure
27
+ Content-Type:
28
+ - application/json
29
+ body:
30
+ encoding: UTF-8
31
+ string: DCD2610ECB6336D5F7F8842EBF6CE01B2D54B8865ECD0B34A87AD4A963370B1F8BA8A0E3F6B9CFAD6CAE6602D7A6FB20BA1176219862C5258BEF0B21FB550A02BA3AC248045A51816F580C569EA1E3EE74B00D8CC6F2A9C97A41D479412FECDEB3B8B78C95CC7C955E42CEFC90140B8E8D2C4C12210E2965E58D3621A1A89DB140836225C49002FC9A5EAC2BC332E691005F5B20C9814FF3EC14F03F763F5EA800C2FE8D01E3D5EF3C3E0715177E0C364A923C76E2FC1F5F2D3F8FC47EE08EBA717227707DBFA11040B6D2853F0B81A96C5104AC4983E57188FB1409340D7AB9A249EAA2FA0100CB2BF07A76743E9EEBB68B0F6576104870CFD524F53C85C02ABEB3EBA3A1C5C4A10880119837FF67E788FB1409340D7AB9A249EAA2FA0100CB2BF07A76743E9EEB50C00D49EAFA3E31DCB5295DBE903E7CFD710E39609AAE58CED62A0E1C6625BB00C2FE8D01E3D5EF3C3E0715177E0C364A923C76E2FC1F5F5EA356372CABACAF997B8362AA473FFF1F72A5209E2FC2DB9C6A69E9509FF7782D74296B1CA52D392D22BCEE8213E79F03CDD72E58377D089E0C0D9889AAFCA070EF59C3B15B47B8997B8362AA473FFF1F72A5209E2FC2DB9C6A69E9509FF77898BFD59E66C58BB49D1925C11E008687EE6267F71499F75C88FB1409340D7AB9A249EAA2FA0100CB2BF07A76743E9EEB50C00D49EAFA3E31B2414187C6EC0B6700C2FE8D01E3D5EF3C3E0715177E0C364A923C76E2FC1F5F2D3F8FC47EE08EBA9639B09A6C98FEB6A421B84395211E10DA53F3742CC8E5EFA0D00D48F5A55EE46888EBB56F3FEE8F88FB1409340D7AB9A249EAA2FA0100CB2BF07A76743E9EEB50C00D49EAFA3E316FE5FD232E2818D54157808C703956D1056275498693929200C2FE8D01E3D5EF3C3E0715177E0C364A923C76E2FC1F5F481DC4F7160B1D2905C0CB89D4F6068350C00D49EAFA3E318167688C7267654D88584CF46174B2FA861AAFDCD3FFF54DF388522AC185B89D71E65AB4625F9E1CD465EC8710220B54BDB74A7249C1806B88FB1409340D7AB9A249EAA2FA0100CB2BF07A76743E9EEBF061B1DBBFDF71E2E7B69E618AECAC6DD81CF04831A78AC9997B8362AA473FFF1F72A5209E2FC2DB9C6A69E9509FF778A5E0C56FD28E92F5DA4250330A3F2D3B23D95300C4FB76DC47BD2739710BE97B88FB1409340D7AB9A249EAA2FA0100CB2BF07A76743E9EEB9B1821AC6B04C46D98280B27631E456DA0A367EC2CADDDE129E058DEDAB82DD9B4FAC4153C30ED2E00C2FE8D01E3D5EF3C3E0715177E0C364A923C76E2FC1F5F799DD8EA29D2E82605C0CB89D4F6068350C00D49EAFA3E318167688C7267654DCED4B21F9139B974698EA500335C2B74F388522AC185B89D351B6342D0E6F280B8B0E70DE3C3B02D8BA8A0E3F6B9CFAD6CAE6602D7A6FB20DB0DA0362400069EE45F7D86E89617ACB3B3F4245CACED35FFE0F860908B58E42D3F8FC47EE08EBA7C6EE8935EA67DB40990EDC372B2F88DC34C3372B65814329C6A69E9509FF7782DBC7DDED2F01849BCEE41CA8EC8807A50C00D49EAFA3E318167688C7267654D870126B3670A3CC3D0107F33C7A2F5A9BB89321629FEC05DA2C0831C69BE688BD28FB6D5CBEC67F67782D446BB63A2C8
32
+ http_version:
33
+ recorded_at: Fri, 19 Dec 2014 23:15:26 GMT
34
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.basecommercesandbox.com/pcms/?f=API_processBankCardTransactionV4
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"gateway_username":"simplefinance1","gateway_password":"brxEY5SxdMjG","payload":"6f50ac65ab0165c440315668ad6ce2092bf07a76743e9eebf6d5201ff01ec0b47cd40b5522b736de397b2d63174a0356189be8836469fbe0aae4f6ca539fa56d3702009a70de293438153c9549274799a7fda9da90e30f404bb002fce56bd525319cf2ed48ee89be8495e2d7f187b7dac82789f2a551195e7e9d821869d6e03d527ea830b2cb359fad570b8c93e1044e9e0ef0e873016fd0d10f780753db243c0f856161c858ee04319cf2ed48ee89be62c1d0c146cf238a605ebde35d6795050f4696cb3441f385bbdf1a45df89a48e4a923c76e2fc1f5f1f058bf4935b3308c6543203281cb6752bc7a9536360ab747c6ee8935ea67db48bd6ef76065371a4f4fa77efe913f72bdc03c5a3ca572503e9463d490103ce8f6967ab918009723798c69a25f578af0d8167688c7267654d68465d4342eb3a44717227707dbfa1105fc5d1796c09b817b507d78c8eb77d06459666d7be5708f99c6a69e9509ff77820eab31aa675736897ca25d968e2812a8c4413b2b6602dccc0dcec0a68e0ff3840315668ad6ce2092bf07a76743e9eeb49b0c5506db882cf960f85bc63f41e94f6ce5c1dc4edb6bb1be39e3d473993334c5fdda885b23db4ba1176219862c525b6658c43b46d228165a589a2c7dcc1961be39e3d473993334c5fdda885b23db428b24f1673a5a5bab9820d8c73233366a1c958ecdc4f200b"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: ''
20
+ headers:
21
+ Date:
22
+ - Fri, 19 Dec 2014 23:57:25 GMT
23
+ Server:
24
+ - Apache/2.4.10 (FreeBSD) OpenSSL/1.0.1j
25
+ Set-Cookie:
26
+ - JSESSIONID=45B0634D160011F877480B3240EE3231; Path=/; Secure
27
+ Content-Type:
28
+ - application/json
29
+ body:
30
+ encoding: UTF-8
31
+ string: 6F50AC65AB0165C440315668AD6CE209FA9689C384A4B1A005C0CB89D4F60683BBDF1A45DF89A48E4A923C76E2FC1F5FB1BFD1BAB9E35B407331334868BF20B3459666D7BE5708F99C6A69E9509FF7782247FB6EE18C7705694A6F5C44AAB09E459666D7BE5708F99C6A69E9509FF7782247FB6EE18C7705F3F34B60BF9D693BB63FF9A597F76E672D1023C6C0C8B5BDFDCE97B8D2B542808C9AE1884022E268CBD2F1F05ACD2F24D8F4CA762F22F54037B2E4B8D621F4974C6A14DD2728748104EDB152AE887ED56A907159F81B0393E4539613D8532CB32035472E754DFE6B7DF2500EB4D98D34A1EE20EF9461AD3F1BE39E3D473993334C5FDDA885B23DB42CCD1E32E63A2DF9B5E2CB5F48A87792B8A7DDF462AAA39113C1F04625260FAC7A9A679139995F1DC0F1CB9743426B762D54B8865ECD0B34C19BC53B05454759B5E2CB5F48A877925F41CB5A6EF8AF79BCEE41CA8EC8807ABBDF1A45DF89A48E4A923C76E2FC1F5F6E3C2B83E9C09F2922E1EB0EF992D824812C9F1E2B7F542F907234EFAF2E6101BEB3EBA3A1C5C4A10880119837FF67E72BC7A9536360AB747C6EE8935EA67DB48BD6EF76065371A4F4FA77EFE913F72BC468028ECC84DE8E65D875A8D98BE08B6967AB918009723798C69A25F578AF0D8167688C7267654DBEE05770C1E4797E98F93A432AA6BC96F3036056818B7863D6FF33AE2234963EC0F1CB9743426B762D54B8865ECD0B34420CA8C9101945CBC23B1C3094E3C159B6D44FD0DCD998691B5DBA21E1BB7476CBD2F1F05ACD2F24D8F4CA762F22F5407BD323F4AD030F1D46AAB9D1E39AD3546FD07C406DD425F3CBD2F1F05ACD2F24D8F4CA762F22F540D8ECCDEE9BB8E2549C6A69E9509FF778ADF68A7237535B35A7A3AD2A72FFEFB8C0F1CB9743426B762D54B8865ECD0B34AE5D91E376C1DAE57A0C8C124A0EF442C0DCEC0A68E0FF3840315668AD6CE2092BF07A76743E9EEBB68B0F6576104870FE030781CAF4960DBBDF1A45DF89A48E4A923C76E2FC1F5F6E3C2B83E9C09F2998B1B8F8525A818ECF071E68D2EC59ADBD408717623B7D996778C1DB417C630A459666D7BE5708F99C6A69E9509FF77820EAB31AA675736897CA25D968E2812A8C4413B2B6602DCCC0DCEC0A68E0FF3840315668AD6CE2092BF07A76743E9EEBE67744942C5EBE2C7C6EE8935EA67DB4D891FC52410474255FE4450E16BA1BEFA2F5D7D59F6BE1D578F39F2513F9106D90DC50632EC9423E6B25BC9DB51F867314BFACEFCA3A5371F74CDE65EDA10E2B08563F7D0E29909AB3C05533FBBE49716D1C3F0238D423B6D7AFCE1653F9E7A9F9E5128AA9BE2918E9F0ECB14FA23597E7E73DE7E0A8BCBEB516F081545A405978C30339839937095DBEC638BCAE82AB25E0842194D8081E476F3A90EC4439E5CF071E68D2EC59ADB83DDABDDA6A974CF8C3177721F12A0818E7D79016DD3AF102BFA0B2F9031561009CB20A36BD36B33EF780318BCCE0C615A266CC120E41A02E3C4C8FEBF0C9A2D0071A91201405D2E20CFBE08C64B53469F96B98DDA23DD452CE165F7298D9CAD5673B3DA322D036A2F5D7D59F6BE1D544CA23D7D56271195EC20F2726D05B4C3D870C499F9A4B478C763FAAD51679DDBEB3EBA3A1C5C4A10A110601484DB074AFEB00DC16AC2CDEABFAC0C361C8362BFBC2F580D0479C3B64DA2F2FF4F871D80F4696CB3441F385BBDF1A45DF89A48E4A923C76E2FC1F5F3E8CFCB26B146D6DEC4E3CE84CE9C74417395843AB418BE55A07DC1BC983A47507997E523403528A2BC7A9536360AB747C6EE8935EA67DB499E6BA5EFD0C30D0B6D44FD0DCD9986965F163262D1166FA459666D7BE5708F99C6A69E9509FF778421BB554274DEA411C0584E4ACC785F54F639C620AE454781BE39E3D473993334C5FDDA885B23DB4A637C53809996E9A18BBA10E8AB15363EC848288C5CFA91CA7124BBBD810D763381063A5D02A1022D106710BB5FE8E6DBB8AB2D09B9B14839E0EF0E873016FD0DC5D392527DBBF157E9D821869D6E03D189BE8836469FBE0AAE4F6CA539FA56D3702009A70DE29341FD94E39DD49D56DCCD811908A2C342C3D9E0A59B9C6C79C1B6F221D6F510483DA5CD2C60C4C360F98EB418BF9824B4D7802FAF5E14928F5DC5DD937F8D1B170B2D0C5EC887C6E643C56555B01CD266A7C796BF4240988005B1DE074B66C7DB7C0F1CB9743426B762D54B8865ECD0B347F994197C62FBB3205C0CB89D4F60683BBDF1A45DF89A48E4A923C76E2FC1F5F9639B09A6C98FEB6A421B84395211E10C8A32DEC4625D5BC19355A9855B7F00645A6F36C84C18E751BE39E3D473993334C5FDDA885B23DB4C4A7A5D7F6841BE0169DD461E6DBB0B66FA8A7DCFCE53EDBCFC2B63578760753
32
+ http_version:
33
+ recorded_at: Fri, 19 Dec 2014 23:57:05 GMT
34
+ recorded_with: VCR 2.9.3
data/spec/factories.rb ADDED
@@ -0,0 +1,95 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :address, class: BasecommSdk::Address do
4
+ name BasecommSdk::Address::NAME[:xs_address_name_billing]
5
+ line1 '123 main st'
6
+ city 'anytown'
7
+ state 'tx'
8
+ zipcode '12345'
9
+ country 'usa'
10
+ end
11
+
12
+ factory :bank_account, class: BasecommSdk::BankAccount do
13
+ name 'My Account'
14
+ account_number '123123123123'
15
+ routing_number '111000025'
16
+ type BasecommSdk::BankAccount::TYPE[:xs_ba_type_checking]
17
+ end
18
+
19
+ factory :bank_account_transaction, class: BasecommSdk::BankAccountTransaction do
20
+ account_number '123123123123'
21
+ account_name 'Roger Rabbit'
22
+ routing_number '111000025'
23
+ effective_date DateTime.parse(Time.now.to_s)
24
+ amount 1020.20
25
+
26
+ trait :checking do
27
+ account_type BasecommSdk::BankAccountTransaction::ACCOUNT_TYPE[
28
+ :xs_bat_account_type_checking]
29
+ end
30
+
31
+ trait :savings do
32
+ account_type BasecommSdk::BankAccountTransaction::ACCOUNT_TYPE[
33
+ :xs_bat_account_type_savings]
34
+ end
35
+
36
+ trait :debit do
37
+ type BasecommSdk::BankAccountTransaction::TYPE[:xs_bat_type_debit]
38
+ amount 20.33
39
+ end
40
+
41
+ trait :credit do
42
+ type BasecommSdk::BankAccountTransaction::TYPE[:xs_bat_type_credit]
43
+ amount(-1.22)
44
+ end
45
+
46
+ trait :reversal do
47
+ type BasecommSdk::BankAccountTransaction::TYPE[:xs_bat_type_reversal]
48
+ amount(-1.22)
49
+ end
50
+
51
+ trait :cancel do
52
+ type BasecommSdk::BankAccountTransaction::TYPE[:xs_bat_type_cancel]
53
+ amount(0)
54
+ end
55
+
56
+ trait :ccd do
57
+ add_attribute :method, BasecommSdk::BankAccountTransaction::METHOD[:xs_bat_method_ccd]
58
+ end
59
+
60
+ trait :ppd do
61
+ add_attribute :method, BasecommSdk::BankAccountTransaction::METHOD[:xs_bat_method_ppd]
62
+ end
63
+
64
+ end
65
+
66
+ factory :bank_card, class: BasecommSdk::BankCard do
67
+ name 'Roger Rabbit'
68
+ number '4111111111111111'
69
+ expiration_month '07'
70
+ expiration_year (Time.now.year + 1).to_s
71
+ association :billing_address, factory: :address
72
+ creation_date Date.today
73
+ last_used_date Date.today
74
+ end
75
+
76
+ factory :bank_card_transaction, class: BasecommSdk::BankCardTransaction do
77
+ card_number '4111111111111111'
78
+ card_name 'BOB JONES'
79
+ expiration_month '10'
80
+ expiration_year (Time.now.year + 4).to_s
81
+ card_cvv2 '111'
82
+ amount 11.20
83
+ association :billing_address, factory: :address
84
+
85
+ trait :capture do
86
+ type BasecommSdk::BankCardTransaction::TYPE[:xs_bct_type_capture]
87
+ end
88
+
89
+ trait :auth do
90
+ type BasecommSdk::BankCardTransaction::TYPE[:xs_bct_type_auth]
91
+ amount(-1)
92
+ end
93
+ end
94
+
95
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ module BasecommSdk
4
+ describe Address, type: :lib do
5
+
6
+ include_context 'class_with_messages'
7
+
8
+ let(:instance) { create(:address) }
9
+ let(:instance_json) { instance.to_json }
10
+ let(:instance_attributes) { attributes_for(:address) }
11
+
12
+ context '#build_from_json' do
13
+ it "returns an #{described_class} instance from the passed JSON" do
14
+ expect(described_class.build_from_json(instance_json)).to be_a(described_class)
15
+ end
16
+ end
17
+
18
+ context '#from_json' do
19
+ it 'is aliased to #build_from_json' do
20
+ expect(described_class.from_json(instance_json)).to be_a(described_class)
21
+ end
22
+ end
23
+
24
+ context '.to_json' do
25
+ it "prepends attribute names with 'address_'" do
26
+ JSON.parse(instance_json).each do |k, _v|
27
+ expect(k.to_s).to match(/^address_/)
28
+ end
29
+ end
30
+
31
+ it 'returns a JSON representation of the instance' do
32
+ expect(is_json?(instance_json)).to eq(true)
33
+
34
+ # prepend test attribute keys with 'address_' for comparison
35
+ comparison_hash = instance_attributes.inject({}) do |myhash, (k, v)|
36
+ myhash["address_#{k}"] = v
37
+ myhash
38
+ end
39
+ expect(JSON.parse(instance_json)).to eq(comparison_hash)
40
+ end
41
+ end
42
+
43
+ context '.qualified_attributes' do
44
+ it 'returns attributes hash with fully qualified keys' do
45
+ attributes = instance.qualified_attributes
46
+ attributes.each do |atr|
47
+ expect(atr).to match(/^address_/)
48
+ end
49
+ end
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ module BasecommSdk
4
+ describe BankAccount, type: :lib do
5
+
6
+ include_context 'class_with_messages'
7
+
8
+ let(:instance) { create(:bank_account) }
9
+ let(:instance_json) { instance.to_json }
10
+ let(:instance_attributes) { attributes_for(:bank_account) }
11
+
12
+ context '#build_from_json' do
13
+ it 'returns an BankAccount instance from the passed JSON' do
14
+ expect(described_class.build_from_json(instance_json)).to be_a(described_class)
15
+ end
16
+ end
17
+
18
+ context '#from_json' do
19
+ it 'is aliased to #build_from_json' do
20
+ expect(described_class.from_json(instance_json)).to be_a(described_class)
21
+ end
22
+ end
23
+
24
+ context '.to_json' do
25
+ it "prepends attribute names with 'bank_account_'" do
26
+ JSON.parse(instance_json).each do |k, _v|
27
+ expect(k.to_s).to match(/^bank_account_/)
28
+ end
29
+ end
30
+
31
+ it 'returns a JSON representation of the instance' do
32
+ expect(is_json?(instance_json)).to eq(true)
33
+
34
+ # prepend test attribute keys with 'bank_account_' for comparison
35
+ comparison_hash = instance_attributes.inject({}) do |myhash, (k, v)|
36
+ myhash["bank_account_#{k}"] = v
37
+ myhash
38
+ end
39
+ expect(JSON.parse(instance_json)).to eq(comparison_hash)
40
+ end
41
+ end
42
+
43
+ context '.qualified_attributes' do
44
+ it 'returns attributes hash with fully qualified keys' do
45
+ attributes = instance.qualified_attributes
46
+ attributes.each do |atr|
47
+ expect(atr).to match(/^bank_account_/)
48
+ end
49
+ end
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ module BasecommSdk
4
+ describe BankAccountTransaction, type: :lib do
5
+
6
+ include_context 'class_with_messages'
7
+
8
+ let(:instance) { create(:bank_account_transaction) }
9
+ let(:instance_json) { instance.to_json }
10
+ let(:instance_attributes) { attributes_for(:bank_account_transaction) }
11
+
12
+ context '.new' do
13
+ it 'accepts non-prefixed attribute keys' do
14
+ bat = described_class.new(account_name: 'bogus')
15
+ expect(bat.account_name).to eq('bogus')
16
+ end
17
+ end
18
+
19
+ context '#build_from_json' do
20
+ it 'returns an Address instance from the passed JSON' do
21
+ expect(described_class.build_from_json(instance_json)).to be_a(described_class)
22
+ end
23
+ end
24
+
25
+ context '#from_json' do
26
+ it 'is aliased to #build_from_json' do
27
+ expect(described_class.from_json(instance_json)).to be_a(described_class)
28
+ end
29
+ end
30
+
31
+ context '.to_json' do
32
+ it "prepends attribute names with 'bank_account_transaction_'" do
33
+ JSON.parse(instance_json).each do |k, _v|
34
+ expect(k.to_s).to match(/^bank_account_transaction_/)
35
+ end
36
+ end
37
+
38
+ it 'returns a JSON representation of the instance' do
39
+ expect(is_json?(instance_json)).to eq(true)
40
+
41
+ # prepend test attribute keys with 'bank_account_transaction_' for comparison
42
+ comparison_hash = instance_attributes.inject({}) do |myhash, (k, v)|
43
+ myhash["bank_account_transaction_#{k}"] = instance.format(v)
44
+ myhash
45
+ end
46
+ expect(JSON.parse(instance_json)).to eq(comparison_hash)
47
+ end
48
+ end
49
+
50
+ context '.qualified_attributes' do
51
+ it 'returns attributes hash with fully qualified keys' do
52
+ attributes = instance.qualified_attributes
53
+ attributes.each do |atr|
54
+ expect(atr).to match(/^bank_account_transaction_/)
55
+ end
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ module BasecommSdk
4
+ describe BankCard, type: :lib do
5
+
6
+ include_context 'class_with_messages'
7
+
8
+ let(:instance) { create(:bank_card) }
9
+ let(:instance_json) { instance.to_json }
10
+ let(:instance_attributes) { attributes_for(:bank_card) }
11
+
12
+ context '#build_from_json' do
13
+ it "returns an #{described_class} instance from the passed JSON" do
14
+ expect(described_class.build_from_json(instance_json)).to be_a(described_class)
15
+ end
16
+ end
17
+
18
+ context '#from_json' do
19
+ it 'is aliased to #build_from_json' do
20
+ expect(described_class.from_json(instance_json)).to be_a(described_class)
21
+ end
22
+ end
23
+
24
+ context '.to_json' do
25
+ it "prepends attribute names with 'bank_card_'" do
26
+ JSON.parse(instance_json).each do |k, _v|
27
+ expect(k.to_s).to match(/^bank_card_/)
28
+ end
29
+ end
30
+
31
+ it 'returns a JSON representation of the instance' do
32
+ expect(is_json?(instance_json)).to eq(true)
33
+
34
+ # prepend test attribute keys with 'bank_card_' for comparison
35
+ comparison_hash = instance_attributes.inject({}) do |myhash, (k, v)|
36
+ myhash["bank_card_#{k}"] = instance.format(v)
37
+ myhash
38
+ end
39
+ # inject the billing address for comparison
40
+ address_hash = JSON.parse(create(:address).to_json)
41
+ comparison_hash.merge!(
42
+ 'bank_card_billing_address' => address_hash
43
+ )
44
+ expect(JSON.parse(instance_json)).to eq(comparison_hash)
45
+ end
46
+ end
47
+
48
+ context '.initialize' do
49
+ it 'initializes a new billing bank_card' do
50
+ expect(instance.billing_address).to be_a(Address)
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ module BasecommSdk
4
+ describe BankCardTransaction, type: :lib do
5
+
6
+ include_context 'class_with_messages'
7
+
8
+ let(:instance) { create(:bank_card_transaction) }
9
+ let(:instance_json) { instance.to_json }
10
+ let(:instance_attributes) { attributes_for(:bank_card_transaction) }
11
+
12
+ context '#build_from_json' do
13
+ it "returns an #{described_class} instance from the passed JSON" do
14
+ expect(described_class.build_from_json(instance_json)).to be_a(described_class)
15
+ end
16
+ end
17
+
18
+ context '#from_json' do
19
+ it 'is aliased to #build_from_json' do
20
+ expect(described_class.from_json(instance_json)).to be_a(described_class)
21
+ end
22
+ end
23
+
24
+ context '.to_json' do
25
+ it "prepends attribute names with 'bank_card_transaction_'" do
26
+ JSON.parse(instance_json).each do |k, _v|
27
+ expect(k.to_s).to match(/^bank_card_transaction_/)
28
+ end
29
+ end
30
+
31
+ it 'returns a JSON representation of the instance' do
32
+ expect(is_json?(instance_json)).to eq(true)
33
+
34
+ # prepend test attribute keys with 'bank_card_transaction_' for comparison
35
+ comparison_hash = instance_attributes.inject({}) do |myhash, (k, v)|
36
+ myhash["bank_card_transaction_#{k}"] = v
37
+ myhash
38
+ end
39
+ # inject the billing address for comparison
40
+ address_hash = JSON.parse(create(:address).to_json)
41
+ comparison_hash.merge!(
42
+ 'bank_card_transaction_billing_address' => address_hash
43
+ )
44
+ expect(JSON.parse(instance_json)).to eq(comparison_hash)
45
+ end
46
+ end
47
+
48
+ context '.initialize' do
49
+ it 'initializes a new billing bank_card_transaction' do
50
+ expect(instance.billing_address).to be_a(Address)
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module BasecommSdk
4
+ describe Base, type: :lib do
5
+
6
+ end
7
+ end