act_as_api_client 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer.json +11 -0
- data/.github/workflows/main.yml +8 -7
- data/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +20 -17
- data/Dockerfile +3 -0
- data/Gemfile +0 -8
- data/Gemfile.lock +2 -2
- data/README.md +6 -8
- data/act_as_api_client.gemspec +9 -4
- data/demo.rb +1 -1
- data/docker-compose.yml +9 -0
- data/lib/act_as_api_client/clients/{github_client.rb → github_repositories_client.rb} +3 -3
- data/lib/act_as_api_client.rb +0 -1
- metadata +110 -12
- data/lib/act_as_api_client/clients/authorize_net_notifications_client.rb +0 -30
- data/lib/act_as_api_client/clients/authorize_net_webhooks_client.rb +0 -42
- data/lib/act_as_api_client/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2879b607f0a39fdba8f0b5c92097320aacafd5e98a23e8082f051e9b95340765
|
4
|
+
data.tar.gz: c694503be26586f6c184f64b1df4084d261c1dae82aede31951fe7aa023d2c10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d94a6752470991a895526ed0a371e34c44a5db3cc7c1f6d9a81a3e38c4d1ba7a3b39ab0a2406277aa407037744b60f2bbe0408197eaf6cccd625b9f80ef767d
|
7
|
+
data.tar.gz: fc1abaa4b3ae8541dd3a67de89d0a74035ebc8d909aab2d1d48f1d2d34b609bd8406aa28a5a864eff3402aa5a922abcfecf6169b022c9408d6eebc8620d9b65d
|
data/.devcontainer.json
ADDED
data/.github/workflows/main.yml
CHANGED
@@ -9,9 +9,9 @@ name: Ruby
|
|
9
9
|
|
10
10
|
on:
|
11
11
|
push:
|
12
|
-
branches: [
|
12
|
+
branches: [main]
|
13
13
|
pull_request:
|
14
|
-
branches: [
|
14
|
+
branches: [main]
|
15
15
|
|
16
16
|
permissions:
|
17
17
|
contents: read
|
@@ -21,7 +21,7 @@ jobs:
|
|
21
21
|
runs-on: ubuntu-latest
|
22
22
|
strategy:
|
23
23
|
matrix:
|
24
|
-
ruby-version: [
|
24
|
+
ruby-version: ["3.0"]
|
25
25
|
steps:
|
26
26
|
- uses: actions/checkout@v3
|
27
27
|
- name: Set up Ruby
|
@@ -35,15 +35,16 @@ jobs:
|
|
35
35
|
runs-on: ubuntu-latest
|
36
36
|
strategy:
|
37
37
|
matrix:
|
38
|
-
|
38
|
+
os: [ubuntu-latest, macos-latest]
|
39
|
+
ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2"]
|
39
40
|
steps:
|
40
41
|
- uses: actions/checkout@v3
|
41
42
|
- name: Set up Ruby
|
42
|
-
uses: ruby/setup-ruby@
|
43
|
+
uses: ruby/setup-ruby@v1
|
43
44
|
with:
|
44
45
|
ruby-version: ${{ matrix.ruby-version }}
|
45
|
-
bundler-cache: true
|
46
|
+
bundler-cache: true
|
46
47
|
- name: Copy credentials file for CI
|
47
48
|
run: mv spec/credentials.example.yml spec/credentials.yml
|
48
49
|
- name: Run tests
|
49
|
-
run: bundle exec rspec
|
50
|
+
run: bundle exec rspec
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -10,61 +10,64 @@
|
|
10
10
|
# Configuration parameters: IgnoredMethods, Max.
|
11
11
|
Metrics/AbcSize:
|
12
12
|
Exclude:
|
13
|
-
-
|
13
|
+
- "lib/act_as_api_client/clients/github_repositories_client.rb"
|
14
14
|
|
15
15
|
# Offense count: 5
|
16
16
|
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods.
|
17
17
|
# ExcludedMethods: refine
|
18
18
|
Metrics/BlockLength:
|
19
19
|
Exclude:
|
20
|
-
-
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
24
|
-
-
|
20
|
+
- "**/*.gemspec"
|
21
|
+
- "spec/act_as_api_client/clients/authorize_net/authorize_net_notifications_client_spec.rb"
|
22
|
+
- "spec/act_as_api_client/clients/github_client/find_by_spec.rb"
|
23
|
+
- "spec/act_as_api_client/clients/github_client/find_spec.rb"
|
24
|
+
- "spec/act_as_api_client/clients/github_client/where_spec.rb"
|
25
25
|
|
26
26
|
# Offense count: 1
|
27
27
|
# Configuration parameters: IgnoredMethods, Max.
|
28
28
|
Metrics/CyclomaticComplexity:
|
29
29
|
Exclude:
|
30
|
-
-
|
30
|
+
- "lib/act_as_api_client/clients/github_repositories_client.rb"
|
31
31
|
|
32
32
|
# Offense count: 2
|
33
33
|
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods.
|
34
34
|
Metrics/MethodLength:
|
35
35
|
Exclude:
|
36
|
-
-
|
37
|
-
-
|
36
|
+
- "lib/act_as_api_client/clients/github_repositories_client.rb"
|
37
|
+
- "lib/act_as_api_client/clients/http_client.rb"
|
38
38
|
|
39
39
|
# Offense count: 2
|
40
40
|
Naming/AccessorMethodName:
|
41
41
|
Exclude:
|
42
|
-
-
|
42
|
+
- "lib/act_as_api_client.rb"
|
43
43
|
|
44
44
|
# Offense count: 1
|
45
45
|
# Configuration parameters: Max.
|
46
46
|
RSpec/ExampleLength:
|
47
47
|
Exclude:
|
48
|
-
-
|
48
|
+
- "spec/act_as_api_client/clients/http_client_spec.rb"
|
49
49
|
|
50
50
|
# Offense count: 2
|
51
51
|
# Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
52
52
|
RSpec/FilePath:
|
53
53
|
Exclude:
|
54
|
-
-
|
55
|
-
-
|
54
|
+
- "spec/act_as_api_client/clients/authorize_net/authorize_net_notifications_client_spec.rb"
|
55
|
+
- "spec/act_as_api_client/clients/authorize_net/authorize_net_webhooks_client_spec.rb"
|
56
|
+
- "spec/act_as_api_client/clients/github_client/find_by_spec.rb"
|
57
|
+
- "spec/act_as_api_client/clients/github_client/find_spec.rb"
|
58
|
+
- "spec/act_as_api_client/clients/github_client/where_spec.rb"
|
56
59
|
|
57
60
|
# Offense count: 3
|
58
61
|
# Configuration parameters: Max.
|
59
62
|
RSpec/NestedGroups:
|
60
63
|
Exclude:
|
61
|
-
-
|
64
|
+
- "spec/act_as_api_client/clients/github_client/find_by_spec.rb"
|
62
65
|
|
63
66
|
# Offense count: 1
|
64
67
|
# Configuration parameters: MinBodyLength.
|
65
68
|
Style/GuardClause:
|
66
69
|
Exclude:
|
67
|
-
-
|
70
|
+
- "lib/act_as_api_client/clients/authorize_net_webhooks_client.rb"
|
68
71
|
|
69
72
|
# Offense count: 4
|
70
73
|
# Cop supports --auto-correct.
|
@@ -72,5 +75,5 @@ Style/GuardClause:
|
|
72
75
|
# URISchemes: http, https
|
73
76
|
Layout/LineLength:
|
74
77
|
Exclude:
|
75
|
-
-
|
76
|
-
-
|
78
|
+
- "lib/act_as_api_client/clients/github_repositories_client.rb"
|
79
|
+
- "spec/support/vcr_setup.rb"
|
data/Dockerfile
ADDED
data/Gemfile
CHANGED
@@ -4,11 +4,3 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in act_as_api_client.gemspec
|
6
6
|
gemspec
|
7
|
-
|
8
|
-
gem "byebug", "~> 11.1"
|
9
|
-
gem "rake", "~> 13.0"
|
10
|
-
gem "rspec", "~> 3.0"
|
11
|
-
gem "rubocop", "~> 0.80"
|
12
|
-
gem "rubocop-rspec", require: false
|
13
|
-
gem "vcr", "~> 6.1"
|
14
|
-
gem "webmock", "~> 3.14"
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# act_as_api_client
|
2
2
|
|
3
|
-
How to create api clients for your application? What is a better way to encapsualte interactions with third APIs? My answer is `act_as_api_client`.
|
3
|
+
How to create api clients for your application? What is a better way to encapsualte interactions with third party APIs? My answer is `act_as_api_client`.
|
4
4
|
|
5
5
|
Let's assume you have a typical Rails or any ruby application and want to play around with an API, Github for example. See the [Usage](https://github.com/Rukomoynikov/act_as_api_client#usage) section to find how to use existing preconfigured API's and encapsulate all logic inside `APIClient` classes.
|
6
6
|
|
7
|
-
_At the moment i experiment in order to make api clients behavior very similiar to `ActiveRecord` models, so out of the box most of the clients support these methods: find, where, delete, update, find_by, create, update_
|
8
|
-
|
9
7
|
## Installation
|
10
8
|
|
11
9
|
Add this line to your application's Gemfile:
|
@@ -25,14 +23,14 @@ Or install it yourself as:
|
|
25
23
|
## Usage
|
26
24
|
|
27
25
|
### Folder for clients:
|
28
|
-
Create a folder in your app for examples `api_clients
|
26
|
+
Create a folder in your app for examples `api_clients`. This will be the place where you will keep all servies responsible for communication with external HTTP APIs.
|
29
27
|
|
30
28
|
### Create API client class:
|
31
|
-
For example you
|
29
|
+
For example, you need to fetch and update Github repositories, then you class may have a form like this:
|
32
30
|
|
33
31
|
```ruby
|
34
32
|
class GithubClient < ApiClient
|
35
|
-
act_as_api_client for: :
|
33
|
+
act_as_api_client for: :github_repositories
|
36
34
|
end
|
37
35
|
```
|
38
36
|
|
@@ -40,9 +38,9 @@ In case you want to provide and use authorization token for Github:
|
|
40
38
|
|
41
39
|
```ruby
|
42
40
|
class GithubClient < ApiClient
|
43
|
-
act_as_api_client for: :
|
41
|
+
act_as_api_client for: :github_repositories,
|
44
42
|
with: {
|
45
|
-
token: <your_token>
|
43
|
+
token: <your_token> # ENV variable of secret
|
46
44
|
}
|
47
45
|
end
|
48
46
|
```
|
data/act_as_api_client.gemspec
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "lib/act_as_api_client/version"
|
4
|
-
|
5
3
|
Gem::Specification.new do |spec|
|
6
4
|
spec.name = "act_as_api_client"
|
7
|
-
spec.version =
|
5
|
+
spec.version = "1.0.0"
|
8
6
|
spec.authors = ["Max Rukomoynikov"]
|
9
7
|
spec.email = ["rukomoynikov@gmail.com"]
|
10
8
|
|
@@ -12,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
12
10
|
spec.description = "Helps you to build reliable API clients in a minute. Just add act_as_api_client to your classes"
|
13
11
|
spec.homepage = "https://rubygems.org/gems/act_as_api_client"
|
14
12
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
16
14
|
|
17
15
|
spec.metadata = {
|
18
16
|
"source_code_uri" => "https://github.com/Rukomoynikov/act_as_api_client",
|
@@ -29,6 +27,13 @@ Gem::Specification.new do |spec|
|
|
29
27
|
spec.require_paths = ["lib"]
|
30
28
|
|
31
29
|
# Uncomment to register a new dependency of your gem
|
30
|
+
spec.add_development_dependency "byebug", "~> 11.1"
|
31
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
spec.add_development_dependency "rubocop", "~> 0.80"
|
34
|
+
spec.add_development_dependency "rubocop-rspec"
|
35
|
+
spec.add_development_dependency "vcr", "~> 6.1"
|
36
|
+
spec.add_development_dependency "webmock", "~> 3.14"
|
32
37
|
|
33
38
|
# For more information and examples about making a new gem, checkout our
|
34
39
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/demo.rb
CHANGED
data/docker-compose.yml
ADDED
@@ -4,7 +4,7 @@ require_relative "http_client"
|
|
4
4
|
|
5
5
|
module ActAsApiClient
|
6
6
|
module Clients
|
7
|
-
module
|
7
|
+
module GithubRepositoriesClient
|
8
8
|
include HttpClient
|
9
9
|
|
10
10
|
# Searches Github for one repository by it's owner and repository names.
|
@@ -30,7 +30,7 @@ module ActAsApiClient
|
|
30
30
|
#
|
31
31
|
# @example Reverse a string
|
32
32
|
# class GithubClient < ApiClient
|
33
|
-
# act_as_api_client for: :
|
33
|
+
# act_as_api_client for: :github_repositories
|
34
34
|
# end
|
35
35
|
#
|
36
36
|
# GithubClient.new.where('rails')
|
@@ -50,7 +50,7 @@ module ActAsApiClient
|
|
50
50
|
#
|
51
51
|
# @example Reverse a string
|
52
52
|
# class GithubClient < ApiClient
|
53
|
-
# act_as_api_client for: :
|
53
|
+
# act_as_api_client for: :github_repositories
|
54
54
|
# end
|
55
55
|
#
|
56
56
|
# GithubClient.new.find_by(organization: 'rails')
|
data/lib/act_as_api_client.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: act_as_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Rukomoynikov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2024-10-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: byebug
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '11.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '11.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.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: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.80'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.80'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rspec
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '6.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '6.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.14'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.14'
|
13
111
|
description: Helps you to build reliable API clients in a minute. Just add act_as_api_client
|
14
112
|
to your classes
|
15
113
|
email:
|
@@ -18,12 +116,14 @@ executables: []
|
|
18
116
|
extensions: []
|
19
117
|
extra_rdoc_files: []
|
20
118
|
files:
|
119
|
+
- ".devcontainer.json"
|
21
120
|
- ".github/workflows/main.yml"
|
22
121
|
- ".gitignore"
|
23
122
|
- ".rspec"
|
24
123
|
- ".rubocop.yml"
|
25
124
|
- ".rubocop_todo.yml"
|
26
125
|
- CODE_OF_CONDUCT.md
|
126
|
+
- Dockerfile
|
27
127
|
- Gemfile
|
28
128
|
- Gemfile.lock
|
29
129
|
- LICENSE.txt
|
@@ -33,13 +133,11 @@ files:
|
|
33
133
|
- bin/console
|
34
134
|
- bin/setup
|
35
135
|
- demo.rb
|
136
|
+
- docker-compose.yml
|
36
137
|
- lib/act_as_api_client.rb
|
37
138
|
- lib/act_as_api_client/base_api_methods.rb
|
38
|
-
- lib/act_as_api_client/clients/
|
39
|
-
- lib/act_as_api_client/clients/authorize_net_webhooks_client.rb
|
40
|
-
- lib/act_as_api_client/clients/github_client.rb
|
139
|
+
- lib/act_as_api_client/clients/github_repositories_client.rb
|
41
140
|
- lib/act_as_api_client/clients/http_client.rb
|
42
|
-
- lib/act_as_api_client/version.rb
|
43
141
|
homepage: https://rubygems.org/gems/act_as_api_client
|
44
142
|
licenses:
|
45
143
|
- MIT
|
@@ -48,7 +146,7 @@ metadata:
|
|
48
146
|
homepage_uri: https://rubygems.org/gems/act_as_api_client
|
49
147
|
documentation_uri: https://rubydoc.info/github/Rukomoynikov/act_as_api_client/main
|
50
148
|
bug_tracker_uri: https://github.com/Rukomoynikov/act_as_api_client/issues
|
51
|
-
post_install_message:
|
149
|
+
post_install_message:
|
52
150
|
rdoc_options: []
|
53
151
|
require_paths:
|
54
152
|
- lib
|
@@ -56,15 +154,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
154
|
requirements:
|
57
155
|
- - ">="
|
58
156
|
- !ruby/object:Gem::Version
|
59
|
-
version: 2.
|
157
|
+
version: 2.6.0
|
60
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
159
|
requirements:
|
62
160
|
- - ">="
|
63
161
|
- !ruby/object:Gem::Version
|
64
162
|
version: '0'
|
65
163
|
requirements: []
|
66
|
-
rubygems_version: 3.
|
67
|
-
signing_key:
|
164
|
+
rubygems_version: 3.0.3.1
|
165
|
+
signing_key:
|
68
166
|
specification_version: 4
|
69
167
|
summary: Collection of predefined API clients
|
70
168
|
test_files: []
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "http_client"
|
4
|
-
require_relative "./authorize_net_webhooks_client"
|
5
|
-
require "base64"
|
6
|
-
|
7
|
-
module ActAsApiClient
|
8
|
-
module Clients
|
9
|
-
module AuthorizeNetNotificationsClient
|
10
|
-
include AuthorizeNetWebhooksClient
|
11
|
-
|
12
|
-
def where(parameters = {})
|
13
|
-
# GET https://apitest.authorize.net/rest/v1/notifications?from_date=2017-03-01&to_date=2017-03-13&offset=0&limit=100
|
14
|
-
# GET https://apitest.authorize.net/rest/v1/notifications?deliveryStatus=Failed
|
15
|
-
# [:from_date, :to_date, :offset, :limit, :deliveryStatus]
|
16
|
-
|
17
|
-
get("https://#{base_uri}/rest/v1/notifications/",
|
18
|
-
headers: { "Authorization" => auth },
|
19
|
-
params: parameters)
|
20
|
-
end
|
21
|
-
|
22
|
-
def find(uuid)
|
23
|
-
raise StandardError, "uuid is not provided" if uuid.empty?
|
24
|
-
|
25
|
-
get("https://#{base_uri}/rest/v1/notifications/#{uuid}",
|
26
|
-
headers: { "Authorization" => auth })
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "http_client"
|
4
|
-
require "base64"
|
5
|
-
|
6
|
-
module ActAsApiClient
|
7
|
-
module Clients
|
8
|
-
module AuthorizeNetWebhooksClient
|
9
|
-
include HttpClient
|
10
|
-
DEFAULT_OPTIONS = {
|
11
|
-
mode: :production
|
12
|
-
}.freeze
|
13
|
-
|
14
|
-
def initialize
|
15
|
-
@options = DEFAULT_OPTIONS.merge(options)
|
16
|
-
end
|
17
|
-
|
18
|
-
def find(uuid)
|
19
|
-
raise StandardError, "uuid is not provided" if uuid.empty?
|
20
|
-
|
21
|
-
get("https://#{base_uri}/rest/v1/webhooks/#{uuid}",
|
22
|
-
headers: { "Authorization" => auth })
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def base_uri
|
28
|
-
if @options[:mode] == :test
|
29
|
-
"apitest.authorize.net"
|
30
|
-
else
|
31
|
-
"authorize.net"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def auth
|
36
|
-
if options[:payment_user]
|
37
|
-
"Basic #{Base64.strict_encode64("#{options[:payment_user]}:#{options[:payment_pass]}")}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|