coinbase_commerce 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +38 -0
  3. data/.gitignore +51 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +21 -0
  6. data/README.md +268 -0
  7. data/Rakefile +6 -0
  8. data/coinbase_commerce.gemspec +28 -0
  9. data/examples/charge.rb +38 -0
  10. data/examples/checkout.rb +61 -0
  11. data/examples/event.rb +26 -0
  12. data/examples/webhook.rb +35 -0
  13. data/lib/coinbase_commerce.rb +42 -0
  14. data/lib/coinbase_commerce/api_errors.rb +157 -0
  15. data/lib/coinbase_commerce/api_resources/base/api_object.rb +206 -0
  16. data/lib/coinbase_commerce/api_resources/base/api_resource.rb +25 -0
  17. data/lib/coinbase_commerce/api_resources/base/create.rb +15 -0
  18. data/lib/coinbase_commerce/api_resources/base/delete.rb +16 -0
  19. data/lib/coinbase_commerce/api_resources/base/list.rb +25 -0
  20. data/lib/coinbase_commerce/api_resources/base/save.rb +18 -0
  21. data/lib/coinbase_commerce/api_resources/base/update.rb +15 -0
  22. data/lib/coinbase_commerce/api_resources/charge.rb +14 -0
  23. data/lib/coinbase_commerce/api_resources/checkout.rb +19 -0
  24. data/lib/coinbase_commerce/api_resources/event.rb +13 -0
  25. data/lib/coinbase_commerce/api_response.rb +48 -0
  26. data/lib/coinbase_commerce/client.rb +120 -0
  27. data/lib/coinbase_commerce/util.rb +59 -0
  28. data/lib/coinbase_commerce/version.rb +3 -0
  29. data/lib/coinbase_commerce/webhooks.rb +52 -0
  30. data/spec/api_resources/base/api_object_spec.rb +156 -0
  31. data/spec/api_resources/base/api_resource_spec.rb +32 -0
  32. data/spec/api_resources/charge_spec.rb +19 -0
  33. data/spec/api_resources/checkout_spec.rb +31 -0
  34. data/spec/api_resources/event_spec.rb +12 -0
  35. data/spec/endpont_spec.rb +103 -0
  36. data/spec/error_spec.rb +58 -0
  37. data/spec/response_spec.rb +43 -0
  38. data/spec/spec_helper.rb +15 -0
  39. data/spec/webhook_spec.rb +36 -0
  40. metadata +161 -0
@@ -0,0 +1,15 @@
1
+ require 'bundler/setup'
2
+ require 'webmock/rspec'
3
+ Bundler.setup
4
+ require 'coinbase_commerce'
5
+
6
+ def mock_item
7
+ {:id => "val", :key => "val"}
8
+ end
9
+
10
+ def mock_list
11
+ {
12
+ :pagination => mock_item,
13
+ :data => [mock_item, mock_item]
14
+ }
15
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ describe CoinbaseCommerce::Webhook do
5
+ PAYLOAD_STR = '{"id":1, "event":{"resource":"event"}}'
6
+ SIG_HEADER = '231055346fa57e134e8a65284147ea2a5776337f4863b62da3f90558ed027d56'
7
+ SECRET = 'e9ff8572755fea16d15b623120bb118da275716dde2c996b54509244c13e1aa6'
8
+
9
+ it "should create Event object when valid payload and signatures" do
10
+ event = CoinbaseCommerce::Webhook.construct_event(PAYLOAD_STR, SIG_HEADER, SECRET)
11
+ expect(event).is_a? CoinbaseCommerce::APIResources::Event
12
+ end
13
+
14
+ it "should raise ParserError when invalid payload" do
15
+ payload = "this is not valid JSON"
16
+ expect {CoinbaseCommerce::Webhook.construct_event(payload, SIG_HEADER, SECRET)}
17
+ .to raise_error JSON::ParserError
18
+ end
19
+
20
+ it "should raise a SignatureVerificationError from a valid JSON payload and an invalid signature header" do
21
+ header = "bad_header"
22
+ expect {CoinbaseCommerce::Webhook.construct_event(PAYLOAD_STR, header, SECRET)}
23
+ .to raise_error CoinbaseCommerce::Errors::SignatureVerificationError
24
+ end
25
+
26
+ it "should raise invalid payload error on nil params" do
27
+ secret = nil
28
+ expect {CoinbaseCommerce::Webhook.construct_event(PAYLOAD_STR, SIG_HEADER, secret)}
29
+ .to raise_error CoinbaseCommerce::Errors::WebhookInvalidPayload
30
+ end
31
+ it "should raise invalid payload error when no event in payload " do
32
+ payload = '{"id":1,"scheduled_for":"2017-01-31T20:50:02Z","attempt_number":1}'
33
+ expect {CoinbaseCommerce::Webhook.construct_event(payload, SIG_HEADER, SECRET)}
34
+ .to raise_error CoinbaseCommerce::Errors::WebhookInvalidPayload
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coinbase_commerce
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.7
5
+ platform: ruby
6
+ authors:
7
+ - Coinbase Commerce
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Client library for Coinbase Commerce API
84
+ email:
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".circleci/config.yml"
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE
93
+ - README.md
94
+ - Rakefile
95
+ - coinbase_commerce.gemspec
96
+ - examples/charge.rb
97
+ - examples/checkout.rb
98
+ - examples/event.rb
99
+ - examples/webhook.rb
100
+ - lib/coinbase_commerce.rb
101
+ - lib/coinbase_commerce/api_errors.rb
102
+ - lib/coinbase_commerce/api_resources/base/api_object.rb
103
+ - lib/coinbase_commerce/api_resources/base/api_resource.rb
104
+ - lib/coinbase_commerce/api_resources/base/create.rb
105
+ - lib/coinbase_commerce/api_resources/base/delete.rb
106
+ - lib/coinbase_commerce/api_resources/base/list.rb
107
+ - lib/coinbase_commerce/api_resources/base/save.rb
108
+ - lib/coinbase_commerce/api_resources/base/update.rb
109
+ - lib/coinbase_commerce/api_resources/charge.rb
110
+ - lib/coinbase_commerce/api_resources/checkout.rb
111
+ - lib/coinbase_commerce/api_resources/event.rb
112
+ - lib/coinbase_commerce/api_response.rb
113
+ - lib/coinbase_commerce/client.rb
114
+ - lib/coinbase_commerce/util.rb
115
+ - lib/coinbase_commerce/version.rb
116
+ - lib/coinbase_commerce/webhooks.rb
117
+ - spec/api_resources/base/api_object_spec.rb
118
+ - spec/api_resources/base/api_resource_spec.rb
119
+ - spec/api_resources/charge_spec.rb
120
+ - spec/api_resources/checkout_spec.rb
121
+ - spec/api_resources/event_spec.rb
122
+ - spec/endpont_spec.rb
123
+ - spec/error_spec.rb
124
+ - spec/response_spec.rb
125
+ - spec/spec_helper.rb
126
+ - spec/webhook_spec.rb
127
+ homepage: https://commerce.coinbase.com/docs/api/
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 2.0.0
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.7.6
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Client library for Coinbase Commerce API
151
+ test_files:
152
+ - spec/api_resources/base/api_object_spec.rb
153
+ - spec/api_resources/base/api_resource_spec.rb
154
+ - spec/api_resources/charge_spec.rb
155
+ - spec/api_resources/checkout_spec.rb
156
+ - spec/api_resources/event_spec.rb
157
+ - spec/endpont_spec.rb
158
+ - spec/error_spec.rb
159
+ - spec/response_spec.rb
160
+ - spec/spec_helper.rb
161
+ - spec/webhook_spec.rb