omcms-ruby-client 1.2.0 → 1.4.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/pull_request_template.md +10 -0
- data/.github/workflows/semantic-pr.yaml +18 -0
- data/.github/workflows/semantic-release.yaml +31 -0
- data/.releaserc.yaml +26 -0
- data/Gemfile +2 -0
- data/README.md +1 -0
- data/Rakefile +3 -1
- data/bin/console +1 -0
- data/lib/omcms/client.rb +11 -14
- data/lib/omcms/middleware/parse_response.rb +3 -1
- data/lib/omcms/middleware/set_header.rb +3 -1
- data/lib/omcms/resource/component.rb +3 -1
- data/lib/omcms/resource/offering.rb +2 -0
- data/lib/omcms/resource/offering_data.rb +3 -1
- data/lib/omcms/resource.rb +4 -2
- data/lib/omcms/response/body.rb +16 -15
- data/lib/omcms/response/component.rb +2 -3
- data/lib/omcms/response/error.rb +17 -15
- data/lib/omcms/response/offering.rb +4 -6
- data/lib/omcms/response/offering_data.rb +2 -3
- data/lib/omcms/version.rb +3 -1
- data/lib/omcms.rb +2 -0
- data/omcms-ruby-client.gemspec +7 -5
- metadata +21 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab39e0ec91ceb944add5ef432e128f57cf100ff63e465a7753d7016c4e3aefdf
|
4
|
+
data.tar.gz: 542fc89c8d2ef2e3a29938aa4b4f107f7c22a2c45c49d07df501a6a40e871733
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c306e712943c1287f268e0f770cf11b38b26631c960185d05f3ff9503abe294d1a6409b515bfc526235af3e2249427e3203d8c3469d1d7e0cd2bb12ea4cfb5cf
|
7
|
+
data.tar.gz: e171d02809aaa2baf2c579dddcc9bae8c0ba5bce249994496edd6ab6f3c5bd6666016bd823a91b07acdabe0c0df75b2a9349fee50a4d9493ca162115e3743cd1
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<!--- Summarize your changes here -->
|
2
|
+
|
3
|
+
## JIRA Issue
|
4
|
+
|
5
|
+
[<change_me>](https://equitymultiple.atlassian.net/browse/<change_me>)
|
6
|
+
|
7
|
+
## Rationale
|
8
|
+
<!--- describe how your changes solve the linked issue -->
|
9
|
+
<!--- if any alternatives were considered, explain the -->
|
10
|
+
<!--- tradeoffs, and how this solution was ultimately chosen -->
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: 'Semantic PR'
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types:
|
6
|
+
- opened
|
7
|
+
- edited
|
8
|
+
- synchronize
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
main:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
steps:
|
14
|
+
# Please look up the latest version at
|
15
|
+
# https://github.com/amannn/action-semantic-pull-request/releases
|
16
|
+
- uses: amannn/action-semantic-pull-request@v5.5.3
|
17
|
+
env:
|
18
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Semantic Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
paths-ignore:
|
8
|
+
- '.github/**'
|
9
|
+
- 'README.md'
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
semantic-release:
|
13
|
+
name: Semantic Release
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
concurrency: semantic-release
|
16
|
+
steps:
|
17
|
+
- name: Checkout
|
18
|
+
uses: actions/checkout@v4.1.7
|
19
|
+
with:
|
20
|
+
persist-credentials: false
|
21
|
+
|
22
|
+
- name: Semantic Release
|
23
|
+
id: semantic
|
24
|
+
uses: cycjimmy/semantic-release-action@v4.1.0
|
25
|
+
with:
|
26
|
+
semantic_version: 19.0.5
|
27
|
+
extra_plugins: |
|
28
|
+
conventional-changelog-conventionalcommits@5.0.0
|
29
|
+
@semantic-release/exec@6.0.3
|
30
|
+
env:
|
31
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
data/.releaserc.yaml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
# The branches on which releases should happen
|
3
|
+
branches:
|
4
|
+
- main
|
5
|
+
plugins:
|
6
|
+
# commit-analyzer determines the type of release by analyzing commits with conventional-changelog
|
7
|
+
# we use the default angular commit message conventions
|
8
|
+
# https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit
|
9
|
+
- "@semantic-release/commit-analyzer"
|
10
|
+
|
11
|
+
# Generate release notes for the commits added since the last release with conventional-changelog
|
12
|
+
- "@semantic-release/release-notes-generator"
|
13
|
+
|
14
|
+
# Update the CHANGELOG.md file
|
15
|
+
- - "@semantic-release/changelog"
|
16
|
+
- changelogFile: CHANGELOG.md
|
17
|
+
|
18
|
+
# Publishes a GitHub "release" and comments on released Pull Requests/Issues.
|
19
|
+
- - "@semantic-release/github"
|
20
|
+
- assets:
|
21
|
+
- CHANGELOG.md
|
22
|
+
|
23
|
+
# Commits release assets (changelog) to the repo
|
24
|
+
- - "@semantic-release/git"
|
25
|
+
- assets:
|
26
|
+
- CHANGELOG.md
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -35,6 +35,7 @@ $omcms = OMCMS::Client.new(
|
|
35
35
|
private_key: ENV["OMCMS_PRIVATE_KEY"],
|
36
36
|
open_timeout: ENV["OMCMS_OPEN_TIMEOUT"], # optional default to 10 seconds
|
37
37
|
timeout: ENV["OMCMS_TIMEOUT"] # optional default to 20 seconds
|
38
|
+
adapter: :httpclient # optional HTTP adapter and defaults to `Faraday.default_adapter`
|
38
39
|
)
|
39
40
|
```
|
40
41
|
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/omcms/client.rb
CHANGED
@@ -1,46 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OMCMS
|
2
4
|
class Client
|
3
5
|
attr_reader :client
|
4
6
|
|
5
7
|
def initialize(opts)
|
6
8
|
configure_credentials(opts)
|
7
|
-
configure_client
|
8
|
-
end
|
9
|
-
|
10
|
-
def faraday &block
|
11
|
-
@faraday = block if block
|
12
|
-
@faraday
|
9
|
+
@client = configure_client
|
13
10
|
end
|
14
11
|
|
15
12
|
def configure_client
|
16
|
-
@
|
13
|
+
@configure_client ||= Faraday.new do |f|
|
17
14
|
f.request :authorization, :basic, @username, @password
|
18
15
|
f.options[:open_timeout] = @open_timeout
|
19
16
|
f.options[:timeout] = @timeout
|
20
17
|
f.request :omcms_set_header
|
21
18
|
f.response :omcms_parse_response
|
22
|
-
f.response :json, :
|
23
|
-
|
24
|
-
f.adapter Faraday.default_adapter unless faraday
|
19
|
+
f.response :json, content_type: /\bjson$/
|
20
|
+
f.adapter @adapter
|
25
21
|
end
|
26
22
|
end
|
27
23
|
|
28
24
|
def offerings
|
29
|
-
OMCMS::Offering.new(@client, @
|
25
|
+
OMCMS::Offering.new(@client, @host, @response)
|
30
26
|
end
|
31
27
|
|
32
28
|
private
|
33
29
|
|
34
30
|
def configure_credentials(opts)
|
35
|
-
raise ArgumentError
|
36
|
-
raise ArgumentError
|
37
|
-
raise ArgumentError
|
31
|
+
raise ArgumentError, "Public Key is missing for the OMCMS client" if opts[:public_key].to_s.empty?
|
32
|
+
raise ArgumentError, "Private Key is missing for the OMCMS client" if opts[:private_key].to_s.empty?
|
33
|
+
raise ArgumentError, "Host is missing for the OMCMS client" if opts[:host].to_s.empty?
|
38
34
|
|
39
35
|
@username = opts[:public_key]
|
40
36
|
@password = opts[:private_key]
|
41
37
|
@host = opts[:host]
|
42
38
|
@open_timeout = opts[:open_timeout] || 10
|
43
39
|
@timeout = opts[:timeout] || 20
|
40
|
+
@adapter = opts[:adapter] || Faraday.default_adapter
|
44
41
|
end
|
45
42
|
end
|
46
43
|
end
|
data/lib/omcms/resource.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OMCMS
|
2
4
|
class Resource
|
3
|
-
def initialize(client,
|
5
|
+
def initialize(client, host = nil, _response = {})
|
4
6
|
@client = client
|
5
7
|
@host = host
|
6
8
|
end
|
@@ -18,7 +20,7 @@ module OMCMS
|
|
18
20
|
|
19
21
|
return response if response.instance_of?(OMCMS::Response::Error)
|
20
22
|
|
21
|
-
response_class(class_name).new(@client,
|
23
|
+
response_class(class_name).new(@client, @host, response)
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
data/lib/omcms/response/body.rb
CHANGED
@@ -1,44 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OMCMS
|
2
4
|
module Response
|
3
5
|
class Body
|
4
6
|
attr_reader :body
|
5
7
|
|
6
|
-
def initialize(client,
|
8
|
+
def initialize(client, host, response)
|
7
9
|
@client = client
|
8
10
|
@body = response.body
|
9
11
|
@host = host
|
10
12
|
end
|
11
13
|
|
12
|
-
def to_json
|
14
|
+
def to_json(*_args)
|
13
15
|
parse(@body)
|
14
16
|
end
|
15
17
|
|
16
18
|
private
|
17
19
|
|
18
20
|
def parse(data = "")
|
19
|
-
if data.
|
20
|
-
return data.keys.
|
21
|
+
if data.instance_of?(Hash)
|
22
|
+
return data.keys.to_h do |attribute|
|
21
23
|
key = snakecase(attribute)
|
22
24
|
[key, parse(data[attribute])]
|
23
|
-
end
|
24
|
-
elsif data.
|
25
|
+
end
|
26
|
+
elsif data.instance_of?(Array)
|
25
27
|
return data.map do |object|
|
26
|
-
|
28
|
+
object.keys.to_h do |attribute|
|
27
29
|
key = snakecase(attribute)
|
28
30
|
[key, parse(object[attribute])]
|
29
|
-
end
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
|
-
|
34
|
+
data
|
33
35
|
end
|
34
36
|
|
35
|
-
|
36
37
|
def snakecase(data = "")
|
37
|
-
data.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
38
|
-
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
39
|
-
.tr(
|
40
|
-
.gsub(/\s/,
|
41
|
-
.gsub(/__+/,
|
38
|
+
data.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
39
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
40
|
+
.tr("-", "_")
|
41
|
+
.gsub(/\s/, "_")
|
42
|
+
.gsub(/__+/, "_")
|
42
43
|
.downcase
|
43
44
|
end
|
44
45
|
end
|
data/lib/omcms/response/error.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OMCMS
|
2
4
|
module Response
|
3
5
|
class Error < StandardError
|
4
6
|
attr_reader :status
|
5
7
|
|
6
|
-
def initialize
|
8
|
+
def initialize(response)
|
9
|
+
super
|
7
10
|
return unless response
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
+
|
12
|
+
response = add_body_to_error(response) unless response.respond_to? :body
|
11
13
|
|
12
14
|
response.body.each do |key, value|
|
13
15
|
instance_variable_set("@#{key}", value)
|
@@ -15,17 +17,17 @@ module OMCMS
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
def to_json
|
19
|
-
|
20
|
-
key = attribute.to_s.gsub(
|
21
|
-
[snakecase(key),
|
22
|
-
end
|
20
|
+
def to_json(*_args)
|
21
|
+
instance_variables.to_h do |attribute|
|
22
|
+
key = attribute.to_s.gsub("@", "")
|
23
|
+
[snakecase(key), instance_variable_get(attribute)]
|
24
|
+
end
|
23
25
|
end
|
24
26
|
|
25
27
|
private
|
26
28
|
|
27
29
|
def add_body_to_error(response)
|
28
|
-
|
30
|
+
Struct.new(
|
29
31
|
body: {
|
30
32
|
name: response.class,
|
31
33
|
message: response.message,
|
@@ -35,11 +37,11 @@ module OMCMS
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def snakecase(data = "")
|
38
|
-
data.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
39
|
-
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
40
|
-
.tr(
|
41
|
-
.gsub(/\s/,
|
42
|
-
.gsub(/__+/,
|
40
|
+
data.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
41
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
42
|
+
.tr("-", "_")
|
43
|
+
.gsub(/\s/, "_")
|
44
|
+
.gsub(/__+/, "_")
|
43
45
|
.downcase
|
44
46
|
end
|
45
47
|
end
|
@@ -1,16 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OMCMS
|
2
4
|
module Response
|
3
5
|
class Offering < Body
|
4
|
-
def initialize(client, data, host)
|
5
|
-
super
|
6
|
-
end
|
7
|
-
|
8
6
|
def components
|
9
|
-
OMCMS::Component.new(@client,
|
7
|
+
OMCMS::Component.new(@client, @host, body)
|
10
8
|
end
|
11
9
|
|
12
10
|
def data
|
13
|
-
OMCMS::OfferingData.new(@client,
|
11
|
+
OMCMS::OfferingData.new(@client, @host, body)
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
data/lib/omcms/version.rb
CHANGED
data/lib/omcms.rb
CHANGED
data/omcms-ruby-client.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path("lib", __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require "omcms/version"
|
@@ -9,11 +11,10 @@ Gem::Specification.new do |spec|
|
|
9
11
|
spec.email = ["pradeep.rawat@equitymultiple.com"]
|
10
12
|
|
11
13
|
spec.summary = "A Ruby SDK for OMCMS APIs"
|
12
|
-
spec.description = "omcms-ruby-client make is simpler to use OMCMS connector APIs
|
14
|
+
spec.description = "omcms-ruby-client make is simpler to use OMCMS connector APIs
|
15
|
+
and integrate with existing Ruby application"
|
13
16
|
spec.homepage = "https://github.com/equitymultiple/omcms-ruby-client"
|
14
|
-
|
15
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
-
spec.metadata["source_code_uri"] = "https://github.com/equitymultiple/omcms-ruby-client"
|
17
|
+
spec.license = nil
|
17
18
|
|
18
19
|
# Specify which files should be added to the gem when it is released.
|
19
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -23,8 +24,9 @@ Gem::Specification.new do |spec|
|
|
23
24
|
spec.bindir = "exe"
|
24
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
26
|
spec.require_paths = ["lib"]
|
27
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
26
28
|
|
27
|
-
spec.add_dependency "faraday", ">=
|
29
|
+
spec.add_dependency "faraday", ">= 2.0", "< 3"
|
28
30
|
|
29
31
|
spec.metadata["rubygems_mfa_required"] = "true"
|
30
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omcms-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pradeep Rawat
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,23 +16,34 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
|
28
|
-
|
29
|
+
version: '2.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
33
|
+
description: |-
|
34
|
+
omcms-ruby-client make is simpler to use OMCMS connector APIs
|
35
|
+
and integrate with existing Ruby application
|
29
36
|
email:
|
30
37
|
- pradeep.rawat@equitymultiple.com
|
31
38
|
executables: []
|
32
39
|
extensions: []
|
33
40
|
extra_rdoc_files: []
|
34
41
|
files:
|
42
|
+
- ".github/pull_request_template.md"
|
43
|
+
- ".github/workflows/semantic-pr.yaml"
|
44
|
+
- ".github/workflows/semantic-release.yaml"
|
35
45
|
- ".gitignore"
|
46
|
+
- ".releaserc.yaml"
|
36
47
|
- ".rspec"
|
37
48
|
- ".travis.yml"
|
38
49
|
- Gemfile
|
@@ -56,10 +67,9 @@ files:
|
|
56
67
|
- lib/omcms/version.rb
|
57
68
|
- omcms-ruby-client.gemspec
|
58
69
|
homepage: https://github.com/equitymultiple/omcms-ruby-client
|
59
|
-
licenses:
|
70
|
+
licenses:
|
71
|
+
-
|
60
72
|
metadata:
|
61
|
-
homepage_uri: https://github.com/equitymultiple/omcms-ruby-client
|
62
|
-
source_code_uri: https://github.com/equitymultiple/omcms-ruby-client
|
63
73
|
rubygems_mfa_required: 'true'
|
64
74
|
post_install_message:
|
65
75
|
rdoc_options: []
|
@@ -69,14 +79,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
79
|
requirements:
|
70
80
|
- - ">="
|
71
81
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
82
|
+
version: 3.2.0
|
73
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
84
|
requirements:
|
75
85
|
- - ">="
|
76
86
|
- !ruby/object:Gem::Version
|
77
87
|
version: '0'
|
78
88
|
requirements: []
|
79
|
-
rubygems_version: 3.
|
89
|
+
rubygems_version: 3.5.19
|
80
90
|
signing_key:
|
81
91
|
specification_version: 4
|
82
92
|
summary: A Ruby SDK for OMCMS APIs
|