paypal-sdk-rest-pmrb 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +15 -0
  3. data/README.md +265 -0
  4. data/Rakefile +15 -0
  5. data/data/DigiCertHighAssuranceEVRootCA.pem +23 -0
  6. data/data/DigiCertSHA2ExtendedValidationServerCA.pem +28 -0
  7. data/data/paypal.crt +193 -0
  8. data/lib/generators/paypal/sdk/USAGE +3 -0
  9. data/lib/generators/paypal/sdk/install_generator.rb +17 -0
  10. data/lib/generators/paypal/sdk/templates/paypal.rb +2 -0
  11. data/lib/generators/paypal/sdk/templates/paypal.yml +29 -0
  12. data/lib/paypal-sdk-core.rb +38 -0
  13. data/lib/paypal-sdk-rest.rb +2 -0
  14. data/lib/paypal-sdk/core/api.rb +20 -0
  15. data/lib/paypal-sdk/core/api/base.rb +169 -0
  16. data/lib/paypal-sdk/core/api/data_types/array_with_block.rb +44 -0
  17. data/lib/paypal-sdk/core/api/data_types/base.rb +225 -0
  18. data/lib/paypal-sdk/core/api/data_types/enum.rb +26 -0
  19. data/lib/paypal-sdk/core/api/data_types/simple_types.rb +52 -0
  20. data/lib/paypal-sdk/core/api/ipn.rb +66 -0
  21. data/lib/paypal-sdk/core/api/rest.rb +177 -0
  22. data/lib/paypal-sdk/core/authentication.rb +66 -0
  23. data/lib/paypal-sdk/core/config.rb +253 -0
  24. data/lib/paypal-sdk/core/credential.rb +16 -0
  25. data/lib/paypal-sdk/core/credential/base.rb +27 -0
  26. data/lib/paypal-sdk/core/credential/certificate.rb +32 -0
  27. data/lib/paypal-sdk/core/credential/signature.rb +22 -0
  28. data/lib/paypal-sdk/core/credential/third_party/subject.rb +25 -0
  29. data/lib/paypal-sdk/core/credential/third_party/token.rb +39 -0
  30. data/lib/paypal-sdk/core/exceptions.rb +112 -0
  31. data/lib/paypal-sdk/core/logging.rb +50 -0
  32. data/lib/paypal-sdk/core/openid_connect.rb +140 -0
  33. data/lib/paypal-sdk/core/openid_connect/api.rb +50 -0
  34. data/lib/paypal-sdk/core/openid_connect/data_types.rb +73 -0
  35. data/lib/paypal-sdk/core/openid_connect/get_api.rb +28 -0
  36. data/lib/paypal-sdk/core/openid_connect/request_data_type.rb +52 -0
  37. data/lib/paypal-sdk/core/openid_connect/set_api.rb +36 -0
  38. data/lib/paypal-sdk/core/util.rb +11 -0
  39. data/lib/paypal-sdk/core/util/http_helper.rb +171 -0
  40. data/lib/paypal-sdk/core/util/oauth_signature.rb +64 -0
  41. data/lib/paypal-sdk/core/util/ordered_hash.rb +165 -0
  42. data/lib/paypal-sdk/rest.rb +39 -0
  43. data/lib/paypal-sdk/rest/api.rb +23 -0
  44. data/lib/paypal-sdk/rest/data_types.rb +2597 -0
  45. data/lib/paypal-sdk/rest/error_hash.rb +39 -0
  46. data/lib/paypal-sdk/rest/get_api.rb +20 -0
  47. data/lib/paypal-sdk/rest/request_data_type.rb +53 -0
  48. data/lib/paypal-sdk/rest/set_api.rb +42 -0
  49. data/lib/paypal-sdk/rest/version.rb +7 -0
  50. data/spec/README.md +22 -0
  51. data/spec/config/cacert.pem +171 -0
  52. data/spec/config/cert_key.pem +33 -0
  53. data/spec/config/paypal.yml +35 -0
  54. data/spec/config/sample_data.yml +3 -0
  55. data/spec/core/api/data_type_spec.rb +289 -0
  56. data/spec/core/api/rest_spec.rb +211 -0
  57. data/spec/core/config_spec.rb +192 -0
  58. data/spec/core/logging_spec.rb +28 -0
  59. data/spec/core/openid_connect_spec.rb +153 -0
  60. data/spec/invoice_examples_spec.rb +38 -0
  61. data/spec/log/http.log +175 -0
  62. data/spec/log/rest_http.log +0 -0
  63. data/spec/payments_examples_spec.rb +437 -0
  64. data/spec/payouts_examples_spec.rb +74 -0
  65. data/spec/rest/data_types_spec.rb +62 -0
  66. data/spec/rest/error_hash_spec.rb +83 -0
  67. data/spec/spec_helper.rb +37 -0
  68. data/spec/subscription_examples_spec.rb +227 -0
  69. data/spec/support/sample_data.rb +5 -0
  70. data/spec/web_profile_examples_spec.rb +106 -0
  71. data/spec/webhooks_examples_spec.rb +93 -0
  72. metadata +177 -0
@@ -0,0 +1,39 @@
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+ class ErrorHash < Core::Util::OrderedHash
5
+ def self.convert(hash)
6
+ error_hash = new
7
+ hash.each{|key, value|
8
+ error_hash[key] = value
9
+ }
10
+ error_hash
11
+ end
12
+
13
+ def []=(key, value)
14
+ value =
15
+ if value.is_a? Hash
16
+ ErrorHash.convert(value)
17
+ elsif value.is_a? Array and value[0].is_a? Hash
18
+ value.map{|array_value| ErrorHash.convert(array_value) }
19
+ else
20
+ value
21
+ end
22
+ super(key, value)
23
+ end
24
+
25
+ def [](name)
26
+ super(name.to_s) || super(name.to_sym)
27
+ end
28
+
29
+ def method_missing(name, *args)
30
+ if keys.include?(name) or keys.include?(name.to_s)
31
+ self[name]
32
+ else
33
+ super
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,20 @@
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+ module GetAPI
5
+ # Get API object
6
+ # === Example
7
+ # Payment.api
8
+ # payment.api
9
+ def api
10
+ @api || parent_api
11
+ end
12
+
13
+ # Parent API object
14
+ def parent_api
15
+ superclass.respond_to?(:api) ? superclass.api : RequestDataType.api
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,53 @@
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+ module RequestDataType
5
+ # Get a local API object or Class level API object
6
+ def api
7
+ @api || self.class.api
8
+ end
9
+
10
+ # Convert Hash object to ErrorHash object
11
+ def error=(hash)
12
+ @error =
13
+ if hash.is_a? Hash
14
+ ErrorHash.convert(hash)
15
+ else
16
+ hash
17
+ end
18
+ end
19
+
20
+ class << self
21
+ # Global API object
22
+ # === Example
23
+ # RequestDataType.api
24
+ def api
25
+ @api ||= API.new
26
+ end
27
+
28
+ # Setter for RequestDataType.api
29
+ # === Example
30
+ # RequestDataType.set_config(..)
31
+ include SetAPI
32
+
33
+ # Configure depended module, when RequestDataType is include.
34
+ # === Example
35
+ # class Payment < DataTypes
36
+ # include RequestDataType
37
+ # end
38
+ # Payment.set_config(..)
39
+ # payment.set_config(..)
40
+ # Payment.api
41
+ # payment.api
42
+ def included(klass)
43
+ klass.class_eval do
44
+ extend GetAPI
45
+ extend SetAPI
46
+ include SetAPI
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,42 @@
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+ module SetAPI
5
+ # Set new api
6
+ # === Examples
7
+ # payment.set_config(:development)
8
+ # payment.set_config(:client_id => "XYZ", :client_secret => "SECRET")
9
+ # payment.set_config
10
+ # payment.api = API.new(:development)
11
+ def set_config(*args)
12
+ if args[0].is_a?(API)
13
+ @api = args[0]
14
+ else
15
+ @api ||= API.new({})
16
+ @api.set_config(*args) # Just override the configuration and Not
17
+ @api
18
+ end
19
+ end
20
+ alias_method :config=, :set_config
21
+ alias_method :set_api, :set_config
22
+ alias_method :api=, :set_config
23
+
24
+ # Override token
25
+ def token=(token)
26
+ set_config( :client_id => nil, :client_secret => nil ).token = token
27
+ end
28
+ alias_method :"auth=", :"token="
29
+
30
+ # Override client id
31
+ def client_id=(client_id)
32
+ set_config(:client_id => client_id).token = nil
33
+ end
34
+
35
+ # Override client secret
36
+ def client_secret=(client_secret)
37
+ set_config(:client_secret => client_secret).token = nil
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,7 @@
1
+ module PayPal
2
+ module SDK
3
+ module REST
4
+ VERSION = "1.8.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ How to run tests
2
+ ================
3
+
4
+ The SDK tests are composed of two groups: unit test group and integration (functional) test group. Integration test group is by default set not to run.
5
+
6
+ - run a single test
7
+ - `$ bundle exec rspec <test-file>:<line-number>`
8
+ - e.g., to run payment create test,
9
+ - `$ bundle exec rspec spec/payments_examples_spec.rb:53`
10
+
11
+ - run multiple tests in the same file
12
+ - Add `:<line-number>` to the above command. For example, in order to execute payment create and payment list tests,
13
+ - `$ bundle exec rspec spec/payments_examples_spec.rb:53:95`
14
+
15
+ - run integration tests
16
+ - This will set the 'integration' flag and will execute functional tests against sandbox.
17
+ - `$ bundle exec rspec --tag integration`
18
+
19
+ - run tests with a specific String
20
+ - `$ bundle exec rspec -e "<string>"`
21
+ - e.g., to run any tests with "Sa" in test description (for the time being, it will be "Sale" tests)
22
+ - `$ bundle exec rspec -e "Sa"`
@@ -0,0 +1,171 @@
1
+ Verisign Class 3 Public Primary Certification Authority
2
+ =======================================================
3
+ -----BEGIN CERTIFICATE-----
4
+ MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVMx
5
+ FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5
6
+ IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVow
7
+ XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz
8
+ IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA
9
+ A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94
10
+ f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol
11
+ hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBAgUAA4GBALtMEivPLCYA
12
+ TxQT3ab7/AoRhIzzKBxnki98tsX63/Dolbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59Ah
13
+ WM1pF+NEHJwZRDmJXNycAA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2Omuf
14
+ Tqj/ZA1k
15
+ -----END CERTIFICATE-----
16
+
17
+ Verisign Class 3 Public Primary Certification Authority - G2
18
+ ============================================================
19
+ -----BEGIN CERTIFICATE-----
20
+ MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVT
21
+ MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
22
+ eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
23
+ biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
24
+ dCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVT
25
+ MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
26
+ eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
27
+ biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
28
+ dCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCO
29
+ FoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71
30
+ lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQAB
31
+ MA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSkU01UbSuvDV1Ai2TT
32
+ 1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7iF6YM40AIOw7n60RzKprxaZLvcRTD
33
+ Oaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpYoJ2daZH9
34
+ -----END CERTIFICATE-----
35
+
36
+
37
+ Verisign Class 3 Public Primary Certification Authority - G3
38
+ ============================================================
39
+ -----BEGIN CERTIFICATE-----
40
+ MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
41
+ UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
42
+ cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
43
+ IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh
44
+ dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw
45
+ CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy
46
+ dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv
47
+ cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg
48
+ Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
49
+ ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1
50
+ EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc
51
+ cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw
52
+ EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj
53
+ 055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA
54
+ ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f
55
+ j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC
56
+ /Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0
57
+ xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa
58
+ t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==
59
+ -----END CERTIFICATE-----
60
+
61
+ Verisign Class 4 Public Primary Certification Authority - G3
62
+ ============================================================
63
+ -----BEGIN CERTIFICATE-----
64
+ MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
65
+ UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
66
+ cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcml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rbsIKr0csKvE+MW8VLADsfKoKm
80
+ fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c2NU8Qh0XwRJd
81
+ RTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/bLvSHgCwIe34QWKCudiyxLtG
82
+ UPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg==
83
+ -----END CERTIFICATE-----
84
+ VeriSign Class 3 Public Primary Certification Authority - G5
85
+ ============================================================
86
+ -----BEGIN CERTIFICATE-----
87
+ MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
88
+ BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
89
+ ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
90
+ IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
91
+ ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
92
+ yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
93
+ biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
94
+ dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
95
+ YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
96
+ ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
97
+ j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
98
+ Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
99
+ Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
100
+ fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
101
+ BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
102
+ Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
103
+ aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
104
+ SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
105
+ X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
106
+ KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
107
+ Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
108
+ ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
109
+ -----END CERTIFICATE-----
110
+ VeriSign Universal Root Certification Authority
111
+ ===============================================
112
+ -----BEGIN CERTIFICATE-----
113
+ MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
114
+ BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
115
+ ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
116
+ IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
117
+ IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
118
+ UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
119
+ cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
120
+ IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
121
+ aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
122
+ 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
123
+ MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
124
+ 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
125
+ AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
126
+ tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
127
+ CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
128
+ a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
129
+ DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
130
+ Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
131
+ Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
132
+ P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
133
+ wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
134
+ mJO37M2CYfE45k+XmCpajQ==
135
+ -----END CERTIFICATE-----
136
+
137
+ VeriSign Class 3 Public Primary Certification Authority - G4
138
+ ============================================================
139
+ -----BEGIN CERTIFICATE-----
140
+ MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
141
+ VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
142
+ b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
143
+ ZSBvbmx5MUUwQw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Verisign Class 3 Public Primary Certification Authority
158
+ =======================================================
159
+ -----BEGIN CERTIFICATE-----
160
+ MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkGA1UEBhMCVVMx
161
+ FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5
162
+ IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVow
163
+ XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz
164
+ IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA
165
+ A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94
166
+ f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol
167
+ hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBABByUqkFFBky
168
+ CEHwxWsKzH4PIRnN5GfcX6kb5sroc50i2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWX
169
+ bj9T/UWZYB2oK0z5XqcJ2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/
170
+ D/xwzoiQ
171
+ -----END CERTIFICATE-----
@@ -0,0 +1,33 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIICXAIBAAKBgQCx/rJhKDRYhs9WZj66FA+HidsrKwvep3g+YNbm1fXmjcg2rEmC
3
+ kq71+Ftw9rx0Uz7vmg6vcsASUgOyeNG7mVB1SsXc6j+JAzZsmpzxHI0Q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BwYXlwYWwu
22
+ Y29tMB4XDTA5MTAxNTA2Mzg1N1oXDTE5MTAxMzA2Mzg1N1owgYAxLTArBgNVBAMU
23
+ JHBsYXRmb18xMjU1MTcwNjk0X2Jpel9hcGkxLmdtYWlsLmNvbTEiMCAGA1UEChMZ
24
+ cGxhdGZvcm0gc2RrJ3MgVGVzdCBTdG9yZTERMA8GA1UEBxMIU2FuIEpvc2UxCzAJ
25
+ BgNVBAgTAkNBMQswCQYDVQQGEwJVUzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC
26
+ gYEAsf6yYSg0WIbPVmY+uhQPh4nbKysL3qd4PmDW5tX15o3INqxJgpKu9fhbcPa8
27
+ dFM+75oOr3LAElIDsnjRu5lQdUrF3Oo/iQM2bJqc8RyNECpvpwTU0jgKeTVp+jWU
28
+ H7twTQCfzKJP4i92ptg1l1enVO+CeuqwacCCX87PZJsPGRsCAwEAAaMNMAswCQYD
29
+ VR0TBAIwADANBgkqhkiG9w0BAQUFAAOBgQCgH3kwXMJtcAaCBQLKz5TGFogJp/C3
30
+ 06MvjYzdbDrx9Rjf/252UhD8dMPUP5FhU1KXduL+KIEYawPbDQ9+lV58JgM12R0p
31
+ EhCODDI/lDvzbfxUnYgkJ5cnFhTZpcAqVzWuinUnG8jAL9XKiEyu/C73ePMPWPbt
32
+ otoWi+Tk828Qlw==
33
+ -----END CERTIFICATE-----
@@ -0,0 +1,35 @@
1
+ test: &default
2
+ client_id: AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS
3
+ client_secret: EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL
4
+ username: jb-us-seller_api1.paypal.com
5
+ password: WX4WTU3S8MY44S7F
6
+ signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
7
+ app_id: APP-80W284485P519543T
8
+ http_timeout: 120
9
+ mode: sandbox
10
+ sandbox_email_address: Platform.sdk.seller@gmail.com
11
+
12
+ development:
13
+ <<: *default
14
+
15
+ with_authentication:
16
+ <<: *default
17
+ client_id: AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS
18
+ client_secret: EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL
19
+
20
+ with_certificate:
21
+ <<: *default
22
+ username: platfo_1255170694_biz_api1.gmail.com
23
+ password: 2DPPKUPKB7DQLXNR
24
+ signature:
25
+ cert_path: <%= File.expand_path("../cert_key.pem", __FILE__) %>
26
+ app_id: APP-80W284485P519543T
27
+
28
+ with_oauth_token:
29
+ <<: *default
30
+ token: 3rMSi3kCmK1Q3.BKxkH29I53R0TRLrSuCO..l8AMOAFM6cQhPTTrfQ
31
+ token_secret: RuE1j8RNRlSuL5T-PSSpVWLvOlI
32
+
33
+ with_proxy:
34
+ <<: *default
35
+ http_proxy: <%= ENV['http_proxy'] %>
@@ -0,0 +1,3 @@
1
+ ipn:
2
+ valid_message: item_number=&residence_country=US&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AXi5tzp0u2U-8QDyy.oC2A1Dhx04&address_country=United+States&address_city=San+Jose&address_status=unconfirmed&business=platfo_1255077030_biz%40gmail.com&payment_status=Pending&transaction_subject=&protection_eligibility=Ineligible&shipping=0.00&payer_id=934EKX9W68RRU&first_name=John&mc_fee=0.38&txn_id=5AL16697HX185734U&quantity=1&receiver_email=platfo_1255077030_biz%40gmail.com&notify_version=3.7&txn_type=web_accept&mc_gross=1.00&payer_status=unverified&mc_currency=USD&test_ipn=1&custom=&payment_date=01%3A48%3A31+Dec+04%2C+2012+PST&payment_fee=0.38&charset=windows-1252&address_country_code=US&payment_gross=1.00&address_zip=95131&ipn_track_id=af0f53159f21e&address_state=CA&receipt_id=4050-1771-4106-3070&pending_reason=paymentreview&tax=0.00&handling_amount=0.00&item_name=&address_name=John+Doe&last_name=Doe&payment_type=instant&receiver_id=HZH2W8NPXUE5W&address_street=1+Main+St
3
+ invalid_message: invalid=invalid
@@ -0,0 +1,289 @@
1
+ require 'spec_helper'
2
+
3
+ describe PayPal::SDK::Core::API::DataTypes::Base do
4
+
5
+ DataType = PayPal::SDK::Core::API::DataTypes::Base
6
+
7
+ class TestCurrency < DataType
8
+
9
+ # Members
10
+ object_of :amount, String
11
+ object_of :desciption, String, :namespace => "ns"
12
+ # Attributes
13
+ add_attribute :currencyID, :namespace => "cc"
14
+ end
15
+
16
+ class TestType < DataType
17
+ object_of :fromCurrency, TestCurrency
18
+ array_of :toCurrency, TestCurrency
19
+ object_of :firstname, String, :name => "first-name"
20
+ end
21
+
22
+ class TestSimpleType < DataType
23
+ include PayPal::SDK::Core::API::DataTypes::SimpleTypes
24
+ object_of :created_on, Date
25
+ object_of :created_at, DateTime
26
+ end
27
+
28
+ class Message < DataType
29
+ object_of :value, String
30
+ end
31
+
32
+ it "should allow content key" do
33
+ message = Message.new("Testing message")
34
+ expect(message.value).to eql "Testing message"
35
+
36
+ message = Message.new(:value => "Testing message")
37
+ expect(message.value).to eql "Testing message"
38
+ end
39
+
40
+ it "should create member object automatically" do
41
+ test_type = TestType.new
42
+ expect(test_type.fromCurrency).to be_a TestCurrency
43
+ expect(test_type.toCurrency).to be_a Array
44
+ expect(test_type.toCurrency[0]).to be_a TestCurrency
45
+ expect(test_type.toCurrency[1]).to be_a TestCurrency
46
+ expect(test_type.toCurrency[0].amount).to eql nil
47
+ expect(test_type.fromCurrency.amount).to eql nil
48
+ expect(test_type.fromCurrency.desciption).to eql nil
49
+ expect(test_type.fromCurrency.currencyID).to eql nil
50
+ end
51
+
52
+ it "should convert the given data to configured type" do
53
+ test_type = TestType.new( :fromCurrency => { :currencyID => "USD", :amount => "50.0"})
54
+ expect(test_type.fromCurrency).to be_a TestCurrency
55
+ expect(test_type.fromCurrency.currencyID).to eql "USD"
56
+ expect(test_type.fromCurrency.amount).to eql "50.0"
57
+ end
58
+
59
+ it "invoice address loads all members of default address object" do
60
+ invoice_address = InvoiceAddress.new(:line1 => "line1", :line2 => "line2", :phone => { :country_code => "123", :national_number => "1231231234", :extension => "123" }, :status => "status" )
61
+ expect(invoice_address).to be_a InvoiceAddress
62
+ expect(invoice_address.phone).to be_a Phone
63
+ expect(invoice_address.line1).to eql "line1"
64
+ expect(invoice_address.line2).to eql "line2"
65
+ expect(invoice_address.status).to eql "status"
66
+ expect(invoice_address.phone.country_code).to eql "123"
67
+ expect(invoice_address.phone.national_number).to eql "1231231234"
68
+ expect(invoice_address.phone.extension).to eql "123"
69
+ end
70
+
71
+ it "billing info converts an address to invoiceaddress automatically" do
72
+ address = Address.new(:line1 => "line1", :line2 => "line2", :status => "status" )
73
+ billing_info = BillingInfo.new({
74
+ :first_name => "Sally",
75
+ :last_name => "Patient",
76
+ :business_name => "Not applicable",
77
+ })
78
+ billing_info.address = address
79
+ expect(billing_info.address).to be_a Address
80
+ expect(billing_info.invoice_address).to be_a InvoiceAddress
81
+ end
82
+
83
+ it "shipping info returns an Address even if set to InvoiceAddress for backwards compatibility" do
84
+ address = InvoiceAddress.new(:line1 => "line1", :line2 => "line2", :status => "status", :phone => { :national_number => "1234567890" } )
85
+ billing_info = BillingInfo.new({
86
+ :first_name => "Sally",
87
+ :last_name => "Patient",
88
+ :business_name => "Not applicable",
89
+ })
90
+ billing_info.address = address
91
+ expect(billing_info.address).to be_a Address
92
+ expect(billing_info.invoice_address).to be_a InvoiceAddress
93
+ expect(billing_info.invoice_address.phone.national_number).to eql "1234567890"
94
+ end
95
+
96
+ it "returns the address and invoice address types in the billing info" do
97
+ billing_info = BillingInfo.new({
98
+ "first_name" => "Sally",
99
+ "last_name" => "Patient",
100
+ "business_name" => "Not applicable",
101
+ "address" => {
102
+ "line1" => "line1Value",
103
+ "phone" => { "country_code" => "123", "national_number" => "1234567890", "extension" => "456" },
104
+ },
105
+ })
106
+ expect(billing_info.address).to be_a Address
107
+ expect(billing_info.address.line1).to eql "line1Value"
108
+ expect(billing_info.invoice_address).to be_a InvoiceAddress
109
+ expect(billing_info.invoice_address.line1).to eql "line1Value"
110
+ expect(billing_info.invoice_address.phone.country_code).to eql "123"
111
+ expect(billing_info.invoice_address.phone.national_number).to eql "1234567890"
112
+ expect(billing_info.invoice_address.phone.extension).to eql "456"
113
+ end
114
+
115
+ it "shipping info converts an address to invoiceaddress automatically" do
116
+ address = Address.new(:line1 => "line1", :line2 => "line2", :status => "status" )
117
+ shipping_info = ShippingInfo.new({
118
+ "first_name" => "Sally",
119
+ "last_name" => "Patient",
120
+ "business_name" => "Not applicable",
121
+ })
122
+ shipping_info.address = address
123
+ expect(shipping_info.address).to be_a Address
124
+ expect(shipping_info.invoice_address).to be_a InvoiceAddress
125
+ end
126
+
127
+ it "shipping info returns an Address even if set to InvoiceAddress for backwards compatibility" do
128
+ address = InvoiceAddress.new(:line1 => "line1", :line2 => "line2", :status => "status", :phone => { :national_number => "1234567890" } )
129
+ shipping_info = ShippingInfo.new({
130
+ "first_name" => "Sally",
131
+ "last_name" => "Patient",
132
+ "business_name" => "Not applicable",
133
+ })
134
+ shipping_info.address = address
135
+ expect(shipping_info.address).to be_a Address
136
+ expect(shipping_info.invoice_address).to be_a InvoiceAddress
137
+ expect(shipping_info.invoice_address.phone.national_number).to eql "1234567890"
138
+ end
139
+
140
+ it "returns the address and invoice address types in the shipping info" do
141
+ shipping_info = ShippingInfo.new({
142
+ "first_name" => "Sally",
143
+ "last_name" => "Patient",
144
+ "business_name" => "Not applicable",
145
+ "address" => {
146
+ "line1" => "line1Value",
147
+ "phone" => { "country_code" => "123", "national_number" => "1234567890", "extension" => "456" },
148
+ },
149
+ })
150
+ expect(shipping_info.address).to be_a Address
151
+ expect(shipping_info.address.line1).to eql "line1Value"
152
+ expect(shipping_info.invoice_address).to be_a InvoiceAddress
153
+ expect(shipping_info.invoice_address.line1).to eql "line1Value"
154
+ expect(shipping_info.invoice_address.phone.country_code).to eql "123"
155
+ expect(shipping_info.invoice_address.phone.national_number).to eql "1234567890"
156
+ expect(shipping_info.invoice_address.phone.extension).to eql "456"
157
+ end
158
+
159
+ it "should allow block with initializer" do
160
+ test_type = TestType.new do
161
+ fromCurrency do
162
+ self.currencyID = "USD"
163
+ self.amount = "50.0"
164
+ end
165
+ end
166
+ expect(test_type.fromCurrency.currencyID).to eql "USD"
167
+ expect(test_type.fromCurrency.amount).to eql "50.0"
168
+ end
169
+
170
+ it "should allow block with member" do
171
+ test_type = TestType.new
172
+ test_type.fromCurrency do
173
+ self.currencyID = "USD"
174
+ self.amount = "50.0"
175
+ end
176
+ expect(test_type.fromCurrency.currencyID).to eql "USD"
177
+ expect(test_type.fromCurrency.amount).to eql "50.0"
178
+ end
179
+
180
+ it "should assign value to attribute" do
181
+ test_currency = TestCurrency.new( :@currencyID => "USD", :amount => "50" )
182
+ expect(test_currency.currencyID).to eql "USD"
183
+ end
184
+
185
+ it "should allow configured Class object" do
186
+ test_currency = TestCurrency.new( :currencyID => "USD", :amount => "50" )
187
+ test_type = TestType.new( :fromCurrency => test_currency )
188
+ expect(test_type.fromCurrency).to eql test_currency
189
+ end
190
+
191
+ it "should allow snakecase" do
192
+ test_type = TestType.new( :from_currency => {} )
193
+ expect(test_type.from_currency).to be_a TestCurrency
194
+ expect(test_type.from_currency).to eql test_type.fromCurrency
195
+ end
196
+
197
+ it "should allow array" do
198
+ test_type = TestType.new( :toCurrency => [{ :currencyID => "USD", :amount => "50.0" }] )
199
+ expect(test_type.toCurrency).to be_a Array
200
+ expect(test_type.toCurrency.first).to be_a TestCurrency
201
+ expect(test_type.toCurrency.first.currencyID).to eql "USD"
202
+ end
203
+
204
+ it "should skip undefind members on initializer" do
205
+ test_type = TestType.new( :notExist => "testing")
206
+ expect do
207
+ test_type.notExist
208
+ end.to raise_error NoMethodError
209
+ expect do
210
+ test_type.notExist = "Value"
211
+ end.to raise_error NoMethodError
212
+ end
213
+
214
+ it "should not convert empty hash" do
215
+ test_type = TestType.new( :fromCurrency => {} )
216
+ expect(test_type.to_hash).to eql({})
217
+ end
218
+
219
+ it "should not convert empty array" do
220
+ test_type = TestType.new( :toCurrency => [] )
221
+ expect(test_type.to_hash).to eql({})
222
+ end
223
+
224
+ it "should not convert array of empty hash" do
225
+ test_type = TestType.new( :toCurrency => [ {} ] )
226
+ expect(test_type.to_hash).to eql({})
227
+ end
228
+
229
+ it "should return empty hash" do
230
+ test_type = TestType.new
231
+ expect(test_type.to_hash).to eql({})
232
+ end
233
+
234
+ it "should convert to hash" do
235
+ test_currency = TestCurrency.new(:amount => "500")
236
+ expect(test_currency.to_hash).to eql("amount" => "500")
237
+ end
238
+
239
+ it "should convert to hash with key as symbol" do
240
+ test_currency = TestCurrency.new(:amount => "500")
241
+ expect(test_currency.to_hash(:symbol => true)).to eql(:amount => "500")
242
+ end
243
+
244
+ it "should convert attribute key with @" do
245
+ test_currency = TestCurrency.new( :currencyID => "USD", :amount => "50" )
246
+ expect(test_currency.to_hash["@currencyID"]).to eql "USD"
247
+ end
248
+
249
+ it "should convert attribute key without @" do
250
+ test_currency = TestCurrency.new( :currencyID => "USD", :amount => "50" )
251
+ expect(test_currency.to_hash(:attribute => false)["currencyID"]).to eql "USD"
252
+ end
253
+
254
+ it "should convert to hash with namespace" do
255
+ test_currency = TestCurrency.new(:currencyID => "USD", :amount => "500", :desciption => "Testing" )
256
+ hash = test_currency.to_hash
257
+ expect(hash["amount"]).to eql "500"
258
+ expect(hash["ns:desciption"]).to eql "Testing"
259
+ expect(hash["@currencyID"]).to eql "USD"
260
+ hash = test_currency.to_hash(:namespace => false)
261
+ expect(hash["amount"]).to eql "500"
262
+ expect(hash["desciption"]).to eql "Testing"
263
+ expect(hash["@currencyID"]).to eql "USD"
264
+ end
265
+
266
+ it "should allow namespace" do
267
+ test_currency = TestCurrency.new(:amount => "500", :"ns:desciption" => "Testing" )
268
+ expect(test_currency.desciption).to eql "Testing"
269
+ end
270
+
271
+ it "should use name option in members" do
272
+ test_type = TestType.new( :firstname => "FirstName")
273
+ expect(test_type.to_hash).to eql({"first-name" => "FirstName" })
274
+ end
275
+
276
+ it "should allow date" do
277
+ date_time = "2010-10-10T10:10:10"
278
+ test_simple_type = TestSimpleType.new( :created_on => date_time, :created_at => date_time )
279
+ expect(test_simple_type.created_on).to be_a Date
280
+ expect(test_simple_type.created_at).to be_a DateTime
281
+ end
282
+
283
+ it "should allow date with value 0" do
284
+ test_simple_type = TestSimpleType.new( :created_at => "0" )
285
+ expect(test_simple_type.created_at).to be_a DateTime
286
+ end
287
+
288
+ end
289
+