omcms-ruby-client 1.2.0 → 1.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/Gemfile +2 -0
- data/Rakefile +3 -1
- data/bin/console +1 -0
- data/lib/omcms/client.rb +10 -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 +3 -0
- data/omcms-ruby-client.gemspec +7 -2
- metadata +29 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b46ca753a8a873163b0932806bb79e938fc68458c8437c562853115c9548395b
|
4
|
+
data.tar.gz: ac3525d85b4d9b6dea51f70d96b2228cf79dda3ff3fe530c939010d03079dba3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 730fb31217a78bfe393d8dd69d893e9a177ecd5899eeecf5910f0dcd4ff79837a6b2169c87826add1affcddecabdc2eaf2055c8fb2a1779810061291ca19da22
|
7
|
+
data.tar.gz: d37727a2f6dd96c26383013c74d2a17b045a0de7ea15afd98a37ecd1b67e0db717d1bea1661fc383f073d2a3e9296032ace1eeba7fade66be9fcda821968b9e2
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/omcms/client.rb
CHANGED
@@ -1,40 +1,36 @@
|
|
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 :httpclient
|
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]
|
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,7 +11,8 @@ 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
17
|
|
15
18
|
spec.metadata["homepage_uri"] = spec.homepage
|
@@ -23,8 +26,10 @@ Gem::Specification.new do |spec|
|
|
23
26
|
spec.bindir = "exe"
|
24
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
28
|
spec.require_paths = ["lib"]
|
29
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
26
30
|
|
27
|
-
spec.add_dependency "faraday", ">=
|
31
|
+
spec.add_dependency "faraday", ">= 2.0", "< 3"
|
32
|
+
spec.add_dependency "faraday-httpclient", "~> 2.0"
|
28
33
|
|
29
34
|
spec.metadata["rubygems_mfa_required"] = "true"
|
30
35
|
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.3.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-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,16 +16,37 @@ 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
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: faraday-httpclient
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
47
|
+
description: |-
|
48
|
+
omcms-ruby-client make is simpler to use OMCMS connector APIs
|
49
|
+
and integrate with existing Ruby application
|
29
50
|
email:
|
30
51
|
- pradeep.rawat@equitymultiple.com
|
31
52
|
executables: []
|
@@ -69,14 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
90
|
requirements:
|
70
91
|
- - ">="
|
71
92
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
93
|
+
version: 2.7.0
|
73
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
95
|
requirements:
|
75
96
|
- - ">="
|
76
97
|
- !ruby/object:Gem::Version
|
77
98
|
version: '0'
|
78
99
|
requirements: []
|
79
|
-
rubygems_version: 3.4.
|
100
|
+
rubygems_version: 3.4.22
|
80
101
|
signing_key:
|
81
102
|
specification_version: 4
|
82
103
|
summary: A Ruby SDK for OMCMS APIs
|