coinbase_commerce_client 0.1.0

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 (36) hide show
  1. checksums.yaml +7 -0
  2. data/.idea/.gitignore +8 -0
  3. data/.idea/coinbase_commerce_client.iml +85 -0
  4. data/.idea/misc.xml +4 -0
  5. data/.idea/modules.xml +8 -0
  6. data/.idea/vcs.xml +6 -0
  7. data/.rspec +3 -0
  8. data/.rubocop.yml +11 -0
  9. data/CODE_OF_CONDUCT.md +84 -0
  10. data/Gemfile +22 -0
  11. data/Gemfile.lock +99 -0
  12. data/LICENSE +21 -0
  13. data/LICENSE.txt +21 -0
  14. data/README.md +267 -0
  15. data/Rakefile +8 -0
  16. data/assets/banner.png +0 -0
  17. data/badge.svg +1 -0
  18. data/lib/coinbase_commerce_client/api_errors.rb +150 -0
  19. data/lib/coinbase_commerce_client/api_resources/base/api_object.rb +203 -0
  20. data/lib/coinbase_commerce_client/api_resources/base/api_resource.rb +23 -0
  21. data/lib/coinbase_commerce_client/api_resources/base/create.rb +12 -0
  22. data/lib/coinbase_commerce_client/api_resources/base/delete.rb +13 -0
  23. data/lib/coinbase_commerce_client/api_resources/base/list.rb +23 -0
  24. data/lib/coinbase_commerce_client/api_resources/base/save.rb +15 -0
  25. data/lib/coinbase_commerce_client/api_resources/base/update.rb +12 -0
  26. data/lib/coinbase_commerce_client/api_resources/charge.rb +11 -0
  27. data/lib/coinbase_commerce_client/api_resources/checkout.rb +15 -0
  28. data/lib/coinbase_commerce_client/api_resources/event.rb +10 -0
  29. data/lib/coinbase_commerce_client/api_response.rb +36 -0
  30. data/lib/coinbase_commerce_client/client.rb +115 -0
  31. data/lib/coinbase_commerce_client/util.rb +57 -0
  32. data/lib/coinbase_commerce_client/version.rb +5 -0
  33. data/lib/coinbase_commerce_client/webhooks.rb +48 -0
  34. data/lib/coinbase_commerce_client.rb +45 -0
  35. data/sig/coinbase_commerce_client.rbs +4 -0
  36. metadata +150 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a9f34093c391c693ffc11f40d67a89b2f2401c2156144d5b8c1808e92482d656
4
+ data.tar.gz: f14707f0574281bfebe9d4ed929b16c1e0da0988da2253afb391b0daefd35678
5
+ SHA512:
6
+ metadata.gz: 29791b039fab0a91e23c3965bf0ed7c14fc90d921048355b8f58ba795a48ac989e43c43a6d12ab47c21a4592d40a7677fa9fbb6a098f1cb620312f5417582649
7
+ data.tar.gz: e6fecf8770323a2270e6340a3a4a00939d435a784f13001a29f290ea662c1d85e2318cf2a809b4cc7053041fe05574068edc551072be6423a856b6be87a2e30f
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
@@ -0,0 +1,85 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="inheritedJdk" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.23, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="byebug (v11.1.3, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="coderay (v1.1.3, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="crack (v0.4.5, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="docile (v1.4.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="faraday (v2.6.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="faraday-net_http (v3.0.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.0.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.6.2, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.2.3, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.2.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="pry (v0.14.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="pry-byebug (v3.10.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="public_suffix (v5.0.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.6.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.36.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.21.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.21.2, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.3, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-shields-badge (v0.1.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.4, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.3.0, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="webmock (v3.18.1, Remote-asdf: ruby-3.1.2-p20) [gem]" level="application" />
51
+ </component>
52
+ <component name="RakeTasksCache">
53
+ <option name="myRootTask">
54
+ <RakeTaskImpl id="rake">
55
+ <subtasks>
56
+ <RakeTaskImpl description="Build coinbase_commerce_client-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
57
+ <RakeTaskImpl id="build">
58
+ <subtasks>
59
+ <RakeTaskImpl description="Generate SHA512 checksum if coinbase_commerce_client-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
60
+ </subtasks>
61
+ </RakeTaskImpl>
62
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
63
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
64
+ <RakeTaskImpl description="Build and install coinbase_commerce_client-0.1.0.gem into system gems" fullCommand="install" id="install" />
65
+ <RakeTaskImpl id="install">
66
+ <subtasks>
67
+ <RakeTaskImpl description="Build and install coinbase_commerce_client-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
68
+ </subtasks>
69
+ </RakeTaskImpl>
70
+ <RakeTaskImpl description="Create tag v0.1.0 and build and push coinbase_commerce_client-0.1.0.gem to http://mygemserver.com" fullCommand="release[remote]" id="release[remote]" />
71
+ <RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
72
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
73
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
74
+ <RakeTaskImpl id="release">
75
+ <subtasks>
76
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
77
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
78
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
79
+ </subtasks>
80
+ </RakeTaskImpl>
81
+ </subtasks>
82
+ </RakeTaskImpl>
83
+ </option>
84
+ </component>
85
+ </module>
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Remote-asdf: ruby-3.1.2-p20" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/coinbase_commerce_client.iml" filepath="$PROJECT_DIR$/.idea/coinbase_commerce_client.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'db/**/*'
4
+ - 'config/**/*'
5
+ - 'libs/**/*'
6
+ Documentation:
7
+ Enabled: false
8
+ Style/FrozenStringLiteralComment:
9
+ Enabled: false
10
+ Style/EndOfLine:
11
+ EnforcedStyle: lf
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at viniciusborgeis@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in coinbase_commerce_client.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem 'faraday', '~> 2.6'
10
+ gem 'multipart-post', '~> 2.0'
11
+
12
+ group :development do
13
+ gem 'pry-byebug', '~> 3.4'
14
+ gem 'rubocop', '~> 1.36', require: false
15
+ end
16
+
17
+ group :test do
18
+ gem 'rspec', '~> 3.0'
19
+ gem 'webmock', '~> 3.18'
20
+ gem 'simplecov', '~> 0.21.2', require: false
21
+ gem 'simplecov-shields-badge', '~> 0.1.0', require: false
22
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,99 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ coinbase_commerce_client (0.1.0)
5
+ faraday (~> 2.6)
6
+ multipart-post (~> 2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.8.1)
12
+ public_suffix (>= 2.0.2, < 6.0)
13
+ ast (2.4.2)
14
+ byebug (11.1.3)
15
+ coderay (1.1.3)
16
+ crack (0.4.5)
17
+ rexml
18
+ diff-lcs (1.5.0)
19
+ docile (1.4.0)
20
+ faraday (2.6.0)
21
+ faraday-net_http (>= 2.0, < 3.1)
22
+ ruby2_keywords (>= 0.0.4)
23
+ faraday-net_http (3.0.1)
24
+ hashdiff (1.0.1)
25
+ json (2.6.2)
26
+ method_source (1.0.0)
27
+ multipart-post (2.2.3)
28
+ parallel (1.22.1)
29
+ parser (3.1.2.1)
30
+ ast (~> 2.4.1)
31
+ pry (0.14.1)
32
+ coderay (~> 1.1)
33
+ method_source (~> 1.0)
34
+ pry-byebug (3.10.1)
35
+ byebug (~> 11.0)
36
+ pry (>= 0.13, < 0.15)
37
+ public_suffix (5.0.0)
38
+ rainbow (3.1.1)
39
+ rake (13.0.6)
40
+ regexp_parser (2.6.0)
41
+ rexml (3.2.5)
42
+ rspec (3.11.0)
43
+ rspec-core (~> 3.11.0)
44
+ rspec-expectations (~> 3.11.0)
45
+ rspec-mocks (~> 3.11.0)
46
+ rspec-core (3.11.0)
47
+ rspec-support (~> 3.11.0)
48
+ rspec-expectations (3.11.1)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.11.0)
51
+ rspec-mocks (3.11.1)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.11.0)
54
+ rspec-support (3.11.1)
55
+ rubocop (1.36.0)
56
+ json (~> 2.3)
57
+ parallel (~> 1.10)
58
+ parser (>= 3.1.2.1)
59
+ rainbow (>= 2.2.2, < 4.0)
60
+ regexp_parser (>= 1.8, < 3.0)
61
+ rexml (>= 3.2.5, < 4.0)
62
+ rubocop-ast (>= 1.20.1, < 2.0)
63
+ ruby-progressbar (~> 1.7)
64
+ unicode-display_width (>= 1.4.0, < 3.0)
65
+ rubocop-ast (1.21.0)
66
+ parser (>= 3.1.1.0)
67
+ ruby-progressbar (1.11.0)
68
+ ruby2_keywords (0.0.5)
69
+ simplecov (0.21.2)
70
+ docile (~> 1.1)
71
+ simplecov-html (~> 0.11)
72
+ simplecov_json_formatter (~> 0.1)
73
+ simplecov-html (0.12.3)
74
+ simplecov-shields-badge (0.1.0)
75
+ simplecov (~> 0.15)
76
+ simplecov_json_formatter (0.1.4)
77
+ unicode-display_width (2.3.0)
78
+ webmock (3.18.1)
79
+ addressable (>= 2.8.0)
80
+ crack (>= 0.3.2)
81
+ hashdiff (>= 0.4.0, < 2.0.0)
82
+
83
+ PLATFORMS
84
+ x86_64-linux
85
+
86
+ DEPENDENCIES
87
+ coinbase_commerce_client!
88
+ faraday (~> 2.6)
89
+ multipart-post (~> 2.0)
90
+ pry-byebug (~> 3.4)
91
+ rake (~> 13.0)
92
+ rspec (~> 3.0)
93
+ rubocop (~> 1.36)
94
+ simplecov (~> 0.21.2)
95
+ simplecov-shields-badge (~> 0.1.0)
96
+ webmock (~> 3.18)
97
+
98
+ BUNDLED WITH
99
+ 2.3.23
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Vinicius Borges
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Vinicius Borges
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,267 @@
1
+ [![Coverage](badge.svg)](https://github.com/viniciusborgeis/coinbase_commerce_client)
2
+ <p>
3
+ <img width="100%" src="https://raw.githubusercontent.com/viniciusborgeis/coinbase_commerce_client/main/assets/banner.png" alt="Solid Vite Templates">
4
+ </p>
5
+
6
+ # Coinbase Commerce Client
7
+ > <sub>This gem is completely inspired by official Coinbase gem [coinbase-commerce-ruby](coinbase-commerce-ruby), unfortunately the oficial gem actually is deprecated, and my motivation is to continue support for this gem</sub>
8
+
9
+ Coinbase Commerce Client Ruby Gem
10
+
11
+ # Table of contents
12
+
13
+ <!--ts-->
14
+ * [Ruby Versions](#ruby-version)
15
+ * [Third Party Libraries and Dependencies](#third-party-libraries-and-dependencies)
16
+ * [Documentation](#documentation)
17
+ * [Installation](#installation)
18
+ * [Usage](#usage)
19
+ * [Checkouts](#checkouts)
20
+ * [Charges](#charges)
21
+ * [Events](#events)
22
+ * [Validating webhook signatures](#validating-webhook-signatures)
23
+ * [Testing and Contributing](#testing-and-contributing)
24
+ <!--te-->
25
+
26
+ ## Ruby Version
27
+ Ruby [2.3 -> 3.1.2] are supported and tested.
28
+
29
+ ## Third Party Libraries and Dependencies
30
+
31
+ The following libraries will be installed when you install the client library:
32
+ * [faraday](https://github.com/lostisland/faraday)
33
+
34
+ ## Documentation
35
+
36
+ For more details visit [Coinbase API docs](https://commerce.coinbase.com/docs/api/).
37
+
38
+ To start using library, you'll need to [create a Coinbase Commmerce account](https://commerce.coinbase.com/signup).
39
+ Once you've created your Coinbase Commerce account, create an ``API_KEY`` in Settings.
40
+
41
+ Next create a ``Client`` object for interacting with the API:
42
+ ```ruby
43
+ require 'coinbase_commerce_client'
44
+ API_KEY = "API KEY"
45
+ client = CoinbaseCommerceClient::Client.new(api_key: API_KEY)
46
+ ```
47
+
48
+ ``Client`` contains links to every Ruby Class representations of the API resources
49
+ ``Checkout, Charge, Invoices, Event``
50
+
51
+ You can call ``list, auto_paging, create, retrieve, modify`` methods from API resource classes
52
+
53
+ ```ruby
54
+ client.charge.create
55
+ client.checkout.auto_paging
56
+ client.event.list
57
+ client.charge.retrieve
58
+ client.checkout.modify
59
+ ```
60
+ as well as ``save, delete, refresh`` methods from API resource class instances.
61
+ ```ruby
62
+ checkout = client.checkout.retrieve <id>
63
+ checkout.refresh
64
+ checkout.save
65
+ checkout.delete
66
+ ```
67
+
68
+ Each API method returns an ``APIObject`` representing the JSON response from the API, all of the models support hash and JSON representation.\
69
+ Also when the response data is parsed into Ruby objects, the appropriate ``APIObject`` subclasses will be used automatically.
70
+ All subclasses of ``APIResource`` class support ``refresh`` method. This will update their attributes and all nested data by making a fresh ``GET`` request to the relevant API endpoint.
71
+
72
+ The client supports handling of common API errors and warnings.
73
+ All errors occuring during the interaction with the API will be raised as exceptions.
74
+
75
+ | Error | Status Code |
76
+ |--------------------------|-------------|
77
+ | APIError | * |
78
+ | InvalidRequestError | 400 |
79
+ | ParamRequiredError | 400 |
80
+ | ValidationError | 400 |
81
+ | AuthenticationError | 401 |
82
+ | ResourceNotFoundError | 404 |
83
+ | RateLimitExceededError | 429 |
84
+ | InternalServerError | 500 |
85
+ | ServiceUnavailableError | 503 |
86
+
87
+
88
+ ## Installation
89
+
90
+ Add this line to your application's Gemfile:
91
+
92
+ ```ruby
93
+ gem 'coinbase_commerce_client'
94
+ ```
95
+ Then execute:
96
+
97
+ ```sh
98
+ bundle install
99
+ ```
100
+
101
+ Or install it yourself as:
102
+
103
+ ```sh
104
+ gem install coinbase_commerce_client
105
+ ```
106
+
107
+ ## Usage
108
+ ```ruby
109
+ require 'coinbase_commerce'
110
+ client = CoinbaseCommerceClient::Client.new(api_key: 'your_api_key')
111
+ ```
112
+ ## Checkouts
113
+ [Checkouts API docs](https://commerce.coinbase.com/docs/api/#checkouts)
114
+ ### Retrieve
115
+ ```ruby
116
+ checkout = client.checkout.retrieve <checkout_id>
117
+ ```
118
+ ### Create
119
+ ```ruby
120
+ checkout_info = {
121
+ "name": "The Sovereign Individual",
122
+ "description": "Mastering the Transition to the Information Age",
123
+ "pricing_type": "fixed_price",
124
+ "local_price": {
125
+ "amount": "1.00",
126
+ "currency": "USD"
127
+ },
128
+ "requested_info": ["name", "email"]
129
+ }
130
+ checkout = client.checkout.create(checkout_info)
131
+ # or
132
+ checkout = client.checkout.create(:name=>'The Sovereign Individual',
133
+ :description=>'Mastering the Transition to the Information Age',
134
+ :pricing_type=>'fixed_price',
135
+ :local_price=>{
136
+ "amount": "100.00",
137
+ "currency": "USD"
138
+ },
139
+ :requested_info=>["name", "email"])
140
+ ```
141
+
142
+ ### Update
143
+ ```ruby
144
+ checkout = client.checkout.retrieve <checkout_id>
145
+ checkout.name = 'new name'
146
+ checkout.save
147
+ # or
148
+ client.checkout.modify(<checkout_id>, "local_price": {
149
+ "amount": "10000.00",
150
+ "currency": "USD"
151
+ })
152
+ ```
153
+
154
+ ### Delete
155
+ ```ruby
156
+ checkout.delete
157
+ ```
158
+ ### List
159
+ ```ruby
160
+ checkouts = client.checkout.list
161
+ ```
162
+ ### Paging list iterations
163
+ ```ruby
164
+ client.checkout.auto_paging do |ch|
165
+ puts ch.id
166
+ end
167
+ ```
168
+
169
+ ## Charges
170
+ [Charges API docs](https://commerce.coinbase.com/docs/api/#charges)
171
+ ### Retrieve
172
+ ```ruby
173
+ charge = client.charge.retrieve <charge_id>
174
+ ```
175
+ ### Create
176
+ ```ruby
177
+ charge_info = {
178
+ "name": "The Sovereign Individual",
179
+ "description": "Mastering the Transition to the Information Age",
180
+ "pricing_type": "fixed_price",
181
+ "local_price": {
182
+ "amount": "1.00",
183
+ "currency": "USD"
184
+ },
185
+ "requested_info": ["name", "email"]
186
+ }
187
+ charge = client.charge.create(charge_info)
188
+ # or
189
+ charge = client.charge.create(:name=>'The Sovereign Individual',
190
+ :description=>'Mastering the Transition to the Information Age',
191
+ :pricing_type=>'fixed_price',
192
+ :local_price=>{
193
+ "amount": "100.00",
194
+ "currency": "USD"
195
+ })
196
+ ```
197
+ ### List
198
+ ```ruby
199
+ charges_list = client.charge.list
200
+ ```
201
+ ### Paging list iterations
202
+ ```ruby
203
+ client.charge.auto_paging do |charge|
204
+ puts charge.id
205
+ end
206
+ ```
207
+
208
+ ## Events
209
+ [Events API Docs](https://commerce.coinbase.com/docs/api/#events)
210
+ ### Retrieve
211
+ ```ruby
212
+ event = client.event.retrieve <event_id>
213
+ ```
214
+ ### List
215
+ ```ruby
216
+ events = client.event.list
217
+ ```
218
+ ### Paging list iterations
219
+ ```ruby
220
+ client.event.auto_paging do |event|
221
+ puts event.id
222
+ end
223
+ ```
224
+
225
+ ## Validating webhook signatures
226
+ You should verify the webhook signatures using our library.
227
+ To perform the verification you'll need to provide the event data, a webhook signature from the request header, and the endpoint’s secret.
228
+ In case of an invalid request signature or request payload, you will receive an appropriate error message.
229
+
230
+ ```ruby
231
+ WEBHOOK_SECRET = 'your_webhook_secret'
232
+ # Using Sinatra
233
+ post '/webhooks' do
234
+ request_payload = request.body.read
235
+ sig_header = request.env['HTTP_X_CC_WEBHOOK_SIGNATURE']
236
+ begin
237
+ event = CoinbaseCommerceClient::Webhook.construct_event(request_payload, sig_header, WEBHOOK_SECRET)
238
+ # event handle
239
+ puts "Received event id=#{event.id}, type=#{event.type}"
240
+ status 200
241
+ # errors handle
242
+ rescue JSON::ParserError => e
243
+ puts "json parse error"
244
+ status 400
245
+ return
246
+ rescue CoinbaseCommerceClient::Errors::SignatureVerificationError => e
247
+ puts "signature verification error"
248
+ status 400
249
+ return
250
+ rescue CoinbaseCommerceClient::Errors::WebhookInvalidPayload => e
251
+ puts "missing request or headers data"
252
+ status 400
253
+ return
254
+ end
255
+ end
256
+ ```
257
+
258
+ ### Testing and Contributing
259
+ Any and all contributions are welcome! The process is simple: fork this repo, make your changes, add tests, run the test suite, and submit a pull request. Tests are run via rspec. To run the tests, clone the repository and then:
260
+
261
+ # Install the requirements
262
+ gem install coinbase_commerce
263
+ rspec spec
264
+
265
+ # or via Bundle
266
+ bundle install
267
+ bundle exec rspec spec