chargehound 2.4.0 → 2.5.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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +24 -0
- data/.github/workflows/rvm.yml +36 -0
- data/CHANGELOG +2 -0
- data/chargehound.gemspec +2 -2
- data/lib/chargehound/error.rb +2 -1
- data/lib/chargehound/version.rb +1 -1
- data/test/error_test.rb +37 -0
- metadata +11 -10
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a82e732eb0a7cdf16eaf13488aa3802d99b14f39ea1270e588ac92f9e6ec7f9
|
4
|
+
data.tar.gz: a14307daea1deb3817aba7767d6f88bc0e84395af7502c55acbc5508415df4f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c2cc970865ac3e79011460b39636fd0fe4399abae617428fb4edd6a59a1ceeca1ae103fcad2fa89f0bfe272da1ae97b05379a6c253ff060e8d4b7544300c711
|
7
|
+
data.tar.gz: 0a821e6464dbac1257fcb0d73a91c58894e97ed2968729b00abdf8e2d311fd2812c5f45c3f7faafe51fc3722031c2138f94755b77e49cec0f6d7bc1e686c6019
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby: [ '2.4', '2.5', '2.6']
|
15
|
+
name: Test Ruby ${{ matrix.ruby }}
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- uses: actions/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
- run: |
|
22
|
+
gem install bundler
|
23
|
+
bundle install --jobs 4 --retry 3
|
24
|
+
bundle exec rake test
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: JRuby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby: [ 'jruby-9.2.9.0', 'jruby-head' ]
|
15
|
+
name: Test Ruby ${{ matrix.ruby }}
|
16
|
+
steps:
|
17
|
+
- name: Install libraries
|
18
|
+
run: sudo apt install haveged
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- name: Set up RVM
|
21
|
+
run: |
|
22
|
+
curl -sSL https://get.rvm.io | bash
|
23
|
+
- name: Set up Ruby
|
24
|
+
run: |
|
25
|
+
source $HOME/.rvm/scripts/rvm
|
26
|
+
rvm install ${{ matrix.ruby }} --binary
|
27
|
+
rvm --default use ${{ matrix.ruby }}
|
28
|
+
- name: Install dependencies
|
29
|
+
run: |
|
30
|
+
source $HOME/.rvm/scripts/rvm
|
31
|
+
gem install bundler --no-document
|
32
|
+
bundle install
|
33
|
+
- name: Run test
|
34
|
+
run: |
|
35
|
+
source $HOME/.rvm/scripts/rvm
|
36
|
+
rake test
|
data/CHANGELOG
CHANGED
data/chargehound.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'chargehound'
|
7
7
|
spec.version = Chargehound::VERSION
|
8
8
|
spec.platform = Gem::Platform::RUBY
|
9
|
-
spec.required_ruby_version = '>=
|
9
|
+
spec.required_ruby_version = '>= 2.0.0'
|
10
10
|
spec.authors = ['Chargehound']
|
11
11
|
spec.email = ['support@chargehound.com']
|
12
12
|
spec.homepage = 'https://www.chargehound.com'
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.add_development_dependency 'bundler'
|
18
18
|
spec.add_development_dependency 'minitest', '~> 5.8'
|
19
|
-
spec.add_development_dependency 'rake', '~>
|
19
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
20
20
|
spec.add_development_dependency 'rubocop', '~> 0.49'
|
21
21
|
spec.add_development_dependency 'webmock', '~> 2.3'
|
22
22
|
|
data/lib/chargehound/error.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Chargehound
|
2
2
|
# Cast Chargehound API errors to custom error types
|
3
3
|
class ChargehoundError < StandardError
|
4
|
-
attr_reader :status, :message
|
4
|
+
attr_reader :status, :message, :type
|
5
5
|
|
6
6
|
def initialize(error_response)
|
7
7
|
@message = error_response['message']
|
8
8
|
@status = error_response['status']
|
9
|
+
@type = error_response['type']
|
9
10
|
status_string = @status.nil? ? '' : "(Status #{@status}) "
|
10
11
|
super("#{status_string}#{message}")
|
11
12
|
end
|
data/lib/chargehound/version.rb
CHANGED
data/test/error_test.rb
CHANGED
@@ -7,6 +7,14 @@ error_response = {
|
|
7
7
|
}
|
8
8
|
}
|
9
9
|
|
10
|
+
error_response_typed = {
|
11
|
+
'error' => {
|
12
|
+
'status' => 400,
|
13
|
+
'message' => 'Bad Request',
|
14
|
+
'type' => 'invalid_request'
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
10
18
|
describe Chargehound::ChargehoundError do
|
11
19
|
before do
|
12
20
|
Chargehound.api_key = 'API_KEY'
|
@@ -44,6 +52,35 @@ describe Chargehound::ChargehoundError do
|
|
44
52
|
end
|
45
53
|
end
|
46
54
|
|
55
|
+
it 'should surface the error type' do
|
56
|
+
stub_request(:any, 'https://api.chargehound.com/v1/disputes').to_raise(StandardError)
|
57
|
+
|
58
|
+
# `assert_raises` has trouble on jruby,
|
59
|
+
# so we simply write the code
|
60
|
+
begin
|
61
|
+
Chargehound::Disputes.list
|
62
|
+
rescue StandardError => error
|
63
|
+
assert(error.is_a?(StandardError))
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should return typed chargehound errors from the API' do
|
68
|
+
stub_request(:any, 'https://api.chargehound.com/v1/disputes')
|
69
|
+
.to_return(status: 400, body: error_response_typed.to_json)
|
70
|
+
|
71
|
+
# `assert_raises` doesn't like Chargehound::ChargehoundBadRequestError,
|
72
|
+
# so we simply write the code
|
73
|
+
begin
|
74
|
+
Chargehound::Disputes.list
|
75
|
+
rescue Chargehound::ChargehoundBadRequestError => error
|
76
|
+
assert(error.is_a?(Chargehound::ChargehoundBadRequestError))
|
77
|
+
assert_equal(400, error.status)
|
78
|
+
assert_equal('Bad Request', error.message)
|
79
|
+
assert_equal('invalid_request', error.type)
|
80
|
+
assert_equal('(Status 400) Bad Request', error.to_s)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
47
84
|
it 'should throw a typed error on timeout' do
|
48
85
|
stub_request(:any, 'https://api.chargehound.com/v1/disputes').to_timeout
|
49
86
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chargehound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chargehound
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,9 +88,10 @@ extensions: []
|
|
88
88
|
extra_rdoc_files:
|
89
89
|
- README.md
|
90
90
|
files:
|
91
|
+
- ".github/workflows/ruby.yml"
|
92
|
+
- ".github/workflows/rvm.yml"
|
91
93
|
- ".gitignore"
|
92
94
|
- ".rubocop.yml"
|
93
|
-
- ".travis.yml"
|
94
95
|
- CHANGELOG
|
95
96
|
- Gemfile
|
96
97
|
- LICENSE
|
@@ -112,7 +113,7 @@ homepage: https://www.chargehound.com
|
|
112
113
|
licenses:
|
113
114
|
- MIT
|
114
115
|
metadata: {}
|
115
|
-
post_install_message:
|
116
|
+
post_install_message:
|
116
117
|
rdoc_options: []
|
117
118
|
require_paths:
|
118
119
|
- lib
|
@@ -120,15 +121,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
121
|
requirements:
|
121
122
|
- - ">="
|
122
123
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
124
|
+
version: 2.0.0
|
124
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
126
|
requirements:
|
126
127
|
- - ">="
|
127
128
|
- !ruby/object:Gem::Version
|
128
129
|
version: '0'
|
129
130
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
131
|
-
signing_key:
|
131
|
+
rubygems_version: 3.1.4
|
132
|
+
signing_key:
|
132
133
|
specification_version: 4
|
133
134
|
summary: Ruby bindings for the Chargehound API
|
134
135
|
test_files:
|