ohme 0.2.0 → 0.3.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/.qlty/.gitignore +7 -0
- data/.qlty/configs/.standard.yml +5 -0
- data/.qlty/configs/.yamllint.yaml +8 -0
- data/.qlty/qlty.toml +101 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +10 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +86 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +10 -0
- data/lib/ohme/api/contact.rb +60 -0
- data/lib/ohme/api/payment.rb +55 -0
- data/lib/ohme/client.rb +113 -0
- data/lib/ohme/configuration.rb +48 -0
- data/lib/ohme/version.rb +5 -0
- data/lib/ohme.rb +13 -0
- data/ohme.gemspec +39 -0
- data/sig/ohme.rbs +37 -0
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62686e7ba1565e397f58914cb322ad608731b2136753a5c92715e8fe5bd594ed
|
4
|
+
data.tar.gz: 651f6284dd5cbb051c0fa3998b388bcbb60930cd0dd03618513cd6245e7ef5f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2c736154335bfa6aa07c52fea5a71b5eb5d7aa34c60b95fac17ad2ae8833670e6df79394c870579e73032616963591c045c9f32fd06ca57a90006fb65e24f68
|
7
|
+
data.tar.gz: f5a35a8a8167f883ffd868a4b7b8f3fc7d1573662a96d0a90b9e586c409924894879c395493ffc8b664565a42d681481047f45cf3d2f143db9becc48ee580559
|
data/.qlty/.gitignore
ADDED
data/.qlty/qlty.toml
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
# This file was automatically generated by `qlty init`.
|
2
|
+
# You can modify it to suit your needs.
|
3
|
+
# We recommend you to commit this file to your repository.
|
4
|
+
#
|
5
|
+
# This configuration is used by both Qlty CLI and Qlty Cloud.
|
6
|
+
#
|
7
|
+
# Qlty CLI -- Code quality toolkit for developers
|
8
|
+
# Qlty Cloud -- Fully automated Code Health Platform
|
9
|
+
#
|
10
|
+
# Try Qlty Cloud: https://qlty.sh
|
11
|
+
#
|
12
|
+
# For a guide to configuration, visit https://qlty.sh/d/config
|
13
|
+
# Or for a full reference, visit https://qlty.sh/d/qlty-toml
|
14
|
+
config_version = "0"
|
15
|
+
|
16
|
+
exclude_patterns = [
|
17
|
+
"*_min.*",
|
18
|
+
"*-min.*",
|
19
|
+
"*.min.*",
|
20
|
+
"**/.yarn/**",
|
21
|
+
"**/*.d.ts",
|
22
|
+
"**/assets/**",
|
23
|
+
"**/bower_components/**",
|
24
|
+
"**/build/**",
|
25
|
+
"**/cache/**",
|
26
|
+
"**/config/**",
|
27
|
+
"**/db/**",
|
28
|
+
"**/deps/**",
|
29
|
+
"**/dist/**",
|
30
|
+
"**/extern/**",
|
31
|
+
"**/external/**",
|
32
|
+
"**/generated/**",
|
33
|
+
"**/Godeps/**",
|
34
|
+
"**/gradlew/**",
|
35
|
+
"**/mvnw/**",
|
36
|
+
"**/node_modules/**",
|
37
|
+
"**/protos/**",
|
38
|
+
"**/seed/**",
|
39
|
+
"**/target/**",
|
40
|
+
"**/templates/**",
|
41
|
+
"**/testdata/**",
|
42
|
+
"**/vendor/**",
|
43
|
+
]
|
44
|
+
|
45
|
+
test_patterns = [
|
46
|
+
"**/test/**",
|
47
|
+
"**/spec/**",
|
48
|
+
"**/*.test.*",
|
49
|
+
"**/*.spec.*",
|
50
|
+
"**/*_test.*",
|
51
|
+
"**/*_spec.*",
|
52
|
+
"**/test_*.*",
|
53
|
+
"**/spec_*.*",
|
54
|
+
]
|
55
|
+
|
56
|
+
[smells]
|
57
|
+
mode = "comment"
|
58
|
+
|
59
|
+
[[source]]
|
60
|
+
name = "default"
|
61
|
+
default = true
|
62
|
+
|
63
|
+
|
64
|
+
[[plugin]]
|
65
|
+
name = "actionlint"
|
66
|
+
|
67
|
+
[[plugin]]
|
68
|
+
name = "checkov"
|
69
|
+
|
70
|
+
[[plugin]]
|
71
|
+
name = "markdownlint"
|
72
|
+
mode = "comment"
|
73
|
+
|
74
|
+
[[plugin]]
|
75
|
+
name = "osv-scanner"
|
76
|
+
|
77
|
+
[[plugin]]
|
78
|
+
name = "prettier"
|
79
|
+
|
80
|
+
[[plugin]]
|
81
|
+
name = "ripgrep"
|
82
|
+
mode = "comment"
|
83
|
+
|
84
|
+
[[plugin]]
|
85
|
+
name = "rubocop"
|
86
|
+
|
87
|
+
[[plugin]]
|
88
|
+
name = "standardrb"
|
89
|
+
|
90
|
+
[[plugin]]
|
91
|
+
name = "trivy"
|
92
|
+
drivers = [
|
93
|
+
"config",
|
94
|
+
"fs-vuln",
|
95
|
+
]
|
96
|
+
|
97
|
+
[[plugin]]
|
98
|
+
name = "trufflehog"
|
99
|
+
|
100
|
+
[[plugin]]
|
101
|
+
name = "yamllint"
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 fabrice.carrega@treize37.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
data/Gemfile.lock
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ohme (0.3.0)
|
5
|
+
typhoeus (>= 1.4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.3)
|
11
|
+
diff-lcs (1.6.1)
|
12
|
+
ethon (0.16.0)
|
13
|
+
ffi (>= 1.15.0)
|
14
|
+
ffi (1.15.5)
|
15
|
+
json (2.10.2)
|
16
|
+
language_server-protocol (3.17.0.4)
|
17
|
+
lint_roller (1.1.0)
|
18
|
+
parallel (1.26.3)
|
19
|
+
parser (3.3.7.4)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
racc
|
22
|
+
prism (1.4.0)
|
23
|
+
racc (1.8.1)
|
24
|
+
rainbow (3.1.1)
|
25
|
+
rake (13.2.1)
|
26
|
+
regexp_parser (2.10.0)
|
27
|
+
rexml (3.4.1)
|
28
|
+
rspec (3.13.0)
|
29
|
+
rspec-core (~> 3.13.0)
|
30
|
+
rspec-expectations (~> 3.13.0)
|
31
|
+
rspec-mocks (~> 3.13.0)
|
32
|
+
rspec-core (3.13.3)
|
33
|
+
rspec-support (~> 3.13.0)
|
34
|
+
rspec-expectations (3.13.3)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.13.0)
|
37
|
+
rspec-mocks (3.13.2)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.13.0)
|
40
|
+
rspec-support (3.13.2)
|
41
|
+
rubocop (1.64.1)
|
42
|
+
json (~> 2.3)
|
43
|
+
language_server-protocol (>= 3.17.0)
|
44
|
+
parallel (~> 1.10)
|
45
|
+
parser (>= 3.3.0.2)
|
46
|
+
rainbow (>= 2.2.2, < 4.0)
|
47
|
+
regexp_parser (>= 1.8, < 3.0)
|
48
|
+
rexml (>= 3.2.5, < 4.0)
|
49
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
50
|
+
ruby-progressbar (~> 1.7)
|
51
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
52
|
+
rubocop-ast (1.44.0)
|
53
|
+
parser (>= 3.3.7.2)
|
54
|
+
prism (~> 1.4)
|
55
|
+
rubocop-performance (1.21.1)
|
56
|
+
rubocop (>= 1.48.1, < 2.0)
|
57
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
58
|
+
ruby-progressbar (1.13.0)
|
59
|
+
standard (1.37.0)
|
60
|
+
language_server-protocol (~> 3.17.0.2)
|
61
|
+
lint_roller (~> 1.0)
|
62
|
+
rubocop (~> 1.64.0)
|
63
|
+
standard-custom (~> 1.0.0)
|
64
|
+
standard-performance (~> 1.4)
|
65
|
+
standard-custom (1.0.2)
|
66
|
+
lint_roller (~> 1.0)
|
67
|
+
rubocop (~> 1.50)
|
68
|
+
standard-performance (1.4.0)
|
69
|
+
lint_roller (~> 1.1)
|
70
|
+
rubocop-performance (~> 1.21.0)
|
71
|
+
typhoeus (1.4.0)
|
72
|
+
ethon (>= 0.9.0)
|
73
|
+
unicode-display_width (2.6.0)
|
74
|
+
|
75
|
+
PLATFORMS
|
76
|
+
x86_64-darwin-20
|
77
|
+
x86_64-linux
|
78
|
+
|
79
|
+
DEPENDENCIES
|
80
|
+
ohme!
|
81
|
+
rake (~> 13.0)
|
82
|
+
rspec (~> 3.0)
|
83
|
+
standard (~> 1.3)
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
2.3.12
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Fabrice Carrega
|
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,61 @@
|
|
1
|
+
# Ohme
|
2
|
+
|
3
|
+
A Ruby connector for the Ohme API, a tool for integrating with the Ohme CRM platform. This gem simplifies interaction with the Ohme API, allowing developers to easily perform operations such as retrieving data, creating resources, and managing entities within the Ohme ecosystem.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
bundle add ohme
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
gem install ohme
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
### Configuration Initialization
|
18
|
+
|
19
|
+
First, configure the Ohme client with your credentials and settings:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'ohme'
|
23
|
+
require 'json'
|
24
|
+
|
25
|
+
config = Ohme::Configuration.new do |c|
|
26
|
+
c.client_name = 'your_client_name'
|
27
|
+
c.client_secret = 'your_client_secret'
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
Then, initialize the client using your configuration:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
client = Ohme::Client.new(config)
|
35
|
+
```
|
36
|
+
|
37
|
+
You can now use the API endpoints. For example, to list contacts:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
contact_api = Ohme::API::Contact.new(client)
|
41
|
+
contacts = contact_api.index
|
42
|
+
puts contacts
|
43
|
+
```
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/Treize37/ohme>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/Treize37/ohme/blob/main/CODE_OF_CONDUCT.md).
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
58
|
+
|
59
|
+
## Code of Conduct
|
60
|
+
|
61
|
+
Everyone interacting in the Ohme project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Treize37/ohme/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ohme
|
4
|
+
module API
|
5
|
+
# The Contact class provides methods to interact with the Ohme API's
|
6
|
+
# contacts endpoint.
|
7
|
+
# It allows you to list, create, read, update, and delete contacts.
|
8
|
+
class Contact
|
9
|
+
# Initializes a new Contact instance with a client.
|
10
|
+
#
|
11
|
+
# @param client [Ohme::Client] An instance of the Ohme client to
|
12
|
+
# make API requests
|
13
|
+
# @return [Ohme::API::Contact] A new instance of the Contact class
|
14
|
+
def initialize(client = Ohme::Client.new)
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetches the list of contacts
|
19
|
+
#
|
20
|
+
# @param params [Hash] Optional query parameters
|
21
|
+
# @return [Hash] The response from the API
|
22
|
+
def index(params = {})
|
23
|
+
@client.get('contacts', params)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Creates a new contact
|
27
|
+
#
|
28
|
+
# @param body [Hash] The contact data to be sent in the request body
|
29
|
+
# @return [Hash] The response from the API
|
30
|
+
def create(body)
|
31
|
+
@client.post('contacts', body)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Updates a contact by ID
|
35
|
+
#
|
36
|
+
# @param id [String] The ID of the contact to update
|
37
|
+
# @param body [Hash] The contact data to be updated
|
38
|
+
# @return [Hash] The response from the API
|
39
|
+
def update(id, body)
|
40
|
+
@client.put("contacts/#{id}", body)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Fetches a contact by ID
|
44
|
+
#
|
45
|
+
# @param id [String] The ID of the contact to retrieve
|
46
|
+
# @return [Hash] The response from the API
|
47
|
+
def show(id)
|
48
|
+
@client.get("contacts/#{id}")
|
49
|
+
end
|
50
|
+
|
51
|
+
# Deletes a contact by ID
|
52
|
+
#
|
53
|
+
# @param id [String] The ID of the contact to delete
|
54
|
+
# @return [nil] The response from the API
|
55
|
+
def delete(id)
|
56
|
+
@client.delete("contacts/#{id}")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ohme
|
4
|
+
module API
|
5
|
+
# The Payment class provides methods to interact with the Ohme API's
|
6
|
+
# payments endpoint.
|
7
|
+
# It allows you to list, create, read, update, and delete payments.
|
8
|
+
class Payment
|
9
|
+
def initialize(client = Ohme::Client.new)
|
10
|
+
@client = client
|
11
|
+
end
|
12
|
+
|
13
|
+
# Fetches the list of payments
|
14
|
+
#
|
15
|
+
# @param params [Hash] Optional query parameters
|
16
|
+
# @return [Hash] The response from the API
|
17
|
+
def index(params = {})
|
18
|
+
@client.get('payments', params)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Creates a new payment
|
22
|
+
#
|
23
|
+
# @param body [Hash] The payment data to be sent in the request body
|
24
|
+
# @return [Hash] The response from the API
|
25
|
+
def create(body)
|
26
|
+
@client.post('payments', body)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Updates a payment by ID
|
30
|
+
#
|
31
|
+
# @param id [String] The ID of the payment to update
|
32
|
+
# @param body [Hash] The payment data to be updated
|
33
|
+
# @return [Hash] The response from the API
|
34
|
+
def update(id, body)
|
35
|
+
@client.put("payments/#{id}", body)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Fetches a payment by ID
|
39
|
+
#
|
40
|
+
# @param id [String] The ID of the payment to retrieve
|
41
|
+
# @return [Hash] The response from the API
|
42
|
+
def show(id)
|
43
|
+
@client.get("payments/#{id}")
|
44
|
+
end
|
45
|
+
|
46
|
+
# Deletes a payment by ID
|
47
|
+
#
|
48
|
+
# @param id [String] The ID of the payment to delete
|
49
|
+
# @return [nil] The response from the API
|
50
|
+
def delete(id)
|
51
|
+
@client.delete("payments/#{id}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/ohme/client.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'typhoeus'
|
4
|
+
require_relative 'configuration'
|
5
|
+
|
6
|
+
module Ohme
|
7
|
+
# Client for interacting with the Ohme API
|
8
|
+
class Client
|
9
|
+
# Initializes the client with the configuration
|
10
|
+
#
|
11
|
+
# @param configuration [Ohme::Configuration] The configuration object
|
12
|
+
# @return [Ohme::Client] A new instance of the Ohme client
|
13
|
+
def initialize(configuration = Ohme::Configuration.new)
|
14
|
+
@configuration = configuration
|
15
|
+
@configuration.validate!
|
16
|
+
end
|
17
|
+
|
18
|
+
# Performs a GET request
|
19
|
+
#
|
20
|
+
# @param endpoint [String] The API endpoint to request
|
21
|
+
# @param params [Hash] Optional query parameters
|
22
|
+
# @return [Hash] The response from the API
|
23
|
+
def get(endpoint, params = {})
|
24
|
+
request(:get, endpoint, params: params)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Performs a POST request
|
28
|
+
#
|
29
|
+
# @param endpoint [String] The API endpoint to request
|
30
|
+
# @param body [Hash] The request body to send
|
31
|
+
# @return [Hash] The response from the API
|
32
|
+
def post(endpoint, body = {})
|
33
|
+
request(:post, endpoint, body: body)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Performs a PUT request
|
37
|
+
#
|
38
|
+
# @param endpoint [String] The API endpoint to request
|
39
|
+
# @param body [Hash] The request body to send
|
40
|
+
# @return [Hash] The response from the API
|
41
|
+
def put(endpoint, body = {})
|
42
|
+
request(:put, endpoint, body: body)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Performs a DELETE request
|
46
|
+
#
|
47
|
+
# @param endpoint [String] The API endpoint to request
|
48
|
+
# @param params [Hash] Optional query parameters
|
49
|
+
# @return [nil] The response from the API (nil for DELETE requests)
|
50
|
+
def delete(endpoint, params = {})
|
51
|
+
request(:delete, endpoint, params: params)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
# Private: Performs an HTTP request
|
57
|
+
#
|
58
|
+
# @param method [Symbol] The HTTP method (get, post, put, delete)
|
59
|
+
# @param endpoint [String] The API endpoint to request
|
60
|
+
# @param options [Hash] Optional parameters for the request
|
61
|
+
# @return [Hash, nil] The parsed response from the API or nil for DELETE
|
62
|
+
def request(method, endpoint, options = {})
|
63
|
+
response = Typhoeus::Request.new(
|
64
|
+
build_url(endpoint),
|
65
|
+
method: method,
|
66
|
+
headers: build_headers,
|
67
|
+
params: options[:params],
|
68
|
+
body: options[:body]&.to_json,
|
69
|
+
timeout: @configuration.timeout
|
70
|
+
).run
|
71
|
+
|
72
|
+
handle_response(response)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Private: Builds the full URL for the API request
|
76
|
+
#
|
77
|
+
# @param endpoint [String] The API endpoint to request
|
78
|
+
# @return [String] The full URL for the request
|
79
|
+
def build_url(endpoint)
|
80
|
+
"#{@configuration.base_url}#{@configuration.version}/#{endpoint}"
|
81
|
+
end
|
82
|
+
|
83
|
+
# Private: Builds the headers for the request
|
84
|
+
#
|
85
|
+
# @return [Hash] The headers to be sent with the request
|
86
|
+
def build_headers
|
87
|
+
{
|
88
|
+
'client-name' => @configuration.client_name,
|
89
|
+
'client-secret' => @configuration.client_secret,
|
90
|
+
'Content-Type' => 'application/json',
|
91
|
+
'Accept' => 'application/json'
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
# Private: Handles the API response
|
96
|
+
#
|
97
|
+
# @param response [Typhoeus::Response] The response from the API
|
98
|
+
# @return [Hash, nil] The parsed response or nil for DELETE requests
|
99
|
+
def handle_response(response)
|
100
|
+
if response.timed_out?
|
101
|
+
raise 'Request timed out. Please check your network connection or increase the timeout.'
|
102
|
+
elsif response.success?
|
103
|
+
# Return nil for DELETE requests with no body
|
104
|
+
return nil if response.body.nil? || response.body.strip.empty?
|
105
|
+
|
106
|
+
# Parse JSON for other successful responses
|
107
|
+
JSON.parse(response.body)
|
108
|
+
else
|
109
|
+
raise "HTTP request failed: #{response.code} - #{response.body}"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ohme
|
4
|
+
# Configuration of the Ohme API client gem.
|
5
|
+
class Configuration
|
6
|
+
attr_accessor :base_url, :client_name, :client_secret, :timeout, :version
|
7
|
+
|
8
|
+
# Initializes the configuration with default values.
|
9
|
+
#
|
10
|
+
# @yield [config] Optional block to configure the client
|
11
|
+
# @return [Ohme::Configuration] A new instance of the configuration
|
12
|
+
def initialize
|
13
|
+
@base_url = 'https://api-ohme.oneheart.fr/api/'
|
14
|
+
@version = 'v1'
|
15
|
+
@timeout = 30
|
16
|
+
yield self if block_given?
|
17
|
+
end
|
18
|
+
|
19
|
+
# Configures the Ohme API client with a block.
|
20
|
+
#
|
21
|
+
# @yield [config] A block to configure the client
|
22
|
+
# @return [Ohme::Configuration] The current configuration instance
|
23
|
+
def configure
|
24
|
+
yield(self) if block_given?
|
25
|
+
end
|
26
|
+
|
27
|
+
# Validates the configuration values.
|
28
|
+
#
|
29
|
+
# @raise [RuntimeError] if required values are missing
|
30
|
+
def validate!
|
31
|
+
error_on('client_name') unless @client_name
|
32
|
+
error_on('client_secret') unless @client_secret
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# Private: Raises an error if a required configuration attribute is missing.
|
38
|
+
#
|
39
|
+
# @param attribute [String] The name of the missing attribute
|
40
|
+
# @raise [RuntimeError] if the attribute is missing
|
41
|
+
def error_on(attribute)
|
42
|
+
raise(
|
43
|
+
"#{attribute} is missing. " \
|
44
|
+
"Please configure Ohme::Configuration.#{attribute}."
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/ohme/version.rb
ADDED
data/lib/ohme.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'ohme/version'
|
4
|
+
require_relative 'ohme/configuration'
|
5
|
+
require_relative 'ohme/client'
|
6
|
+
require_relative 'ohme/api/contact'
|
7
|
+
require_relative 'ohme/api/payment'
|
8
|
+
|
9
|
+
# Ohme API client gem main module.
|
10
|
+
module Ohme
|
11
|
+
class Error < StandardError; end
|
12
|
+
# Your code goes here...
|
13
|
+
end
|
data/ohme.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/ohme/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'ohme'
|
7
|
+
spec.version = Ohme::VERSION
|
8
|
+
spec.authors = ['Fabrice Carrega']
|
9
|
+
spec.email = ['fabrice.carrega@treize37.com']
|
10
|
+
|
11
|
+
spec.summary = 'API client for the Ohme CRM.'
|
12
|
+
spec.description = 'API client for the Ohme CRM.'
|
13
|
+
spec.homepage = 'https://github.com/treize37/ohme'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 2.6.0'
|
16
|
+
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
+
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
21
|
+
spec.metadata['changelog_uri'] = 'https://github.com/Treize37/ohme/blob/main/CHANGELOG.md'
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(__dir__) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
spec.add_dependency 'typhoeus', '>= 1.4'
|
36
|
+
|
37
|
+
# For more information and examples about making a new gem, check out our
|
38
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
+
end
|
data/sig/ohme.rbs
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ohme
|
4
|
+
VERSION: String
|
5
|
+
|
6
|
+
module Configuration
|
7
|
+
def self.configure: () { (config: Configuration) -> void } -> void
|
8
|
+
def self.validate!: () -> void
|
9
|
+
|
10
|
+
attr_accessor client_secret: String?
|
11
|
+
attr_accessor base_url: String?
|
12
|
+
attr_accessor timeout: Integer?
|
13
|
+
attr_accessor client_name: String?
|
14
|
+
attr_accessor version: String?
|
15
|
+
end
|
16
|
+
|
17
|
+
class Client
|
18
|
+
def initialize: () -> void
|
19
|
+
|
20
|
+
def get: (String, params: Hash[String, untyped]?) -> Hash[String, untyped]?
|
21
|
+
def post: (String, body: Hash[String, untyped]?) -> Hash[String, untyped]?
|
22
|
+
def put: (String, body: Hash[String, untyped]?) -> Hash[String, untyped]?
|
23
|
+
def delete: (String, params: Hash[String, untyped]?) -> nil
|
24
|
+
end
|
25
|
+
|
26
|
+
module API
|
27
|
+
class Contact
|
28
|
+
def initialize: (Ohme::Client?) -> void
|
29
|
+
|
30
|
+
def index: (params: Hash[String, untyped]?) -> Hash[String, untyped]?
|
31
|
+
def create: (body: Hash[String, untyped]) -> Hash[String, untyped]?
|
32
|
+
def update: (String, body: Hash[String, untyped]) -> Hash[String, untyped]?
|
33
|
+
def show: (String) -> Hash[String, untyped]?
|
34
|
+
def delete: (String) -> nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabrice Carrega
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -30,7 +30,27 @@ email:
|
|
30
30
|
executables: []
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
|
-
files:
|
33
|
+
files:
|
34
|
+
- ".qlty/.gitignore"
|
35
|
+
- ".qlty/configs/.standard.yml"
|
36
|
+
- ".qlty/configs/.yamllint.yaml"
|
37
|
+
- ".qlty/qlty.toml"
|
38
|
+
- ".rspec"
|
39
|
+
- CHANGELOG.md
|
40
|
+
- CODE_OF_CONDUCT.md
|
41
|
+
- Gemfile
|
42
|
+
- Gemfile.lock
|
43
|
+
- LICENSE.txt
|
44
|
+
- README.md
|
45
|
+
- Rakefile
|
46
|
+
- lib/ohme.rb
|
47
|
+
- lib/ohme/api/contact.rb
|
48
|
+
- lib/ohme/api/payment.rb
|
49
|
+
- lib/ohme/client.rb
|
50
|
+
- lib/ohme/configuration.rb
|
51
|
+
- lib/ohme/version.rb
|
52
|
+
- ohme.gemspec
|
53
|
+
- sig/ohme.rbs
|
34
54
|
homepage: https://github.com/treize37/ohme
|
35
55
|
licenses:
|
36
56
|
- MIT
|