primary_connect_client 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +72 -0
- data/README.md +100 -0
- data/Rakefile +10 -0
- data/git_push.sh +58 -0
- data/lib/primary_connect_client/api/default_api.rb +390 -0
- data/lib/primary_connect_client/api_client.rb +390 -0
- data/lib/primary_connect_client/api_error.rb +57 -0
- data/lib/primary_connect_client/configuration.rb +293 -0
- data/lib/primary_connect_client/version.rb +5 -0
- data/lib/primary_connect_client.rb +38 -0
- data/primary_connect_client.gemspec +36 -0
- data/spec/api/default_api_spec.rb +112 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/protobuf/address_spec.rb +9 -0
- data/spec/spec_helper.rb +111 -0
- metadata +120 -0
@@ -0,0 +1,293 @@
|
|
1
|
+
=begin
|
2
|
+
#Primary Connect API V1
|
3
|
+
|
4
|
+
#Client Library to interface with Primary Connect
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.3.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
module PrimaryConnectClient
|
14
|
+
class Configuration
|
15
|
+
# Defines url scheme
|
16
|
+
attr_accessor :scheme
|
17
|
+
|
18
|
+
# Defines url host
|
19
|
+
attr_accessor :host
|
20
|
+
|
21
|
+
# Defines url base path
|
22
|
+
attr_accessor :base_path
|
23
|
+
|
24
|
+
# Define server configuration index
|
25
|
+
attr_accessor :server_index
|
26
|
+
|
27
|
+
# Define server operation configuration index
|
28
|
+
attr_accessor :server_operation_index
|
29
|
+
|
30
|
+
# Default server variables
|
31
|
+
attr_accessor :server_variables
|
32
|
+
|
33
|
+
# Default server operation variables
|
34
|
+
attr_accessor :server_operation_variables
|
35
|
+
|
36
|
+
# Defines API keys used with API Key authentications.
|
37
|
+
#
|
38
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
39
|
+
#
|
40
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
41
|
+
# config.api_key['api_key'] = 'xxx'
|
42
|
+
attr_accessor :api_key
|
43
|
+
|
44
|
+
# Defines API key prefixes used with API Key authentications.
|
45
|
+
#
|
46
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
47
|
+
#
|
48
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
49
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
50
|
+
attr_accessor :api_key_prefix
|
51
|
+
|
52
|
+
# Defines the username used with HTTP basic authentication.
|
53
|
+
#
|
54
|
+
# @return [String]
|
55
|
+
attr_accessor :username
|
56
|
+
|
57
|
+
# Defines the password used with HTTP basic authentication.
|
58
|
+
#
|
59
|
+
# @return [String]
|
60
|
+
attr_accessor :password
|
61
|
+
|
62
|
+
# Defines the access token (Bearer) used with OAuth2.
|
63
|
+
attr_accessor :access_token
|
64
|
+
|
65
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
66
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
67
|
+
# Default to false.
|
68
|
+
#
|
69
|
+
# @return [true, false]
|
70
|
+
attr_accessor :debugging
|
71
|
+
|
72
|
+
# Defines the logger used for debugging.
|
73
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
74
|
+
#
|
75
|
+
# @return [#debug]
|
76
|
+
attr_accessor :logger
|
77
|
+
|
78
|
+
# Defines the temporary folder to store downloaded files
|
79
|
+
# (for API endpoints that have file response).
|
80
|
+
# Default to use `Tempfile`.
|
81
|
+
#
|
82
|
+
# @return [String]
|
83
|
+
attr_accessor :temp_folder_path
|
84
|
+
|
85
|
+
# The time limit for HTTP request in seconds.
|
86
|
+
# Default to 0 (never times out).
|
87
|
+
attr_accessor :timeout
|
88
|
+
|
89
|
+
# Set this to false to skip client side validation in the operation.
|
90
|
+
# Default to true.
|
91
|
+
# @return [true, false]
|
92
|
+
attr_accessor :client_side_validation
|
93
|
+
|
94
|
+
### TLS/SSL setting
|
95
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
96
|
+
# Default to true.
|
97
|
+
#
|
98
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
99
|
+
#
|
100
|
+
# @return [true, false]
|
101
|
+
attr_accessor :verify_ssl
|
102
|
+
|
103
|
+
### TLS/SSL setting
|
104
|
+
# Set this to false to skip verifying SSL host name
|
105
|
+
# Default to true.
|
106
|
+
#
|
107
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
108
|
+
#
|
109
|
+
# @return [true, false]
|
110
|
+
attr_accessor :verify_ssl_host
|
111
|
+
|
112
|
+
### TLS/SSL setting
|
113
|
+
# Set this to customize the certificate file to verify the peer.
|
114
|
+
#
|
115
|
+
# @return [String] the path to the certificate file
|
116
|
+
#
|
117
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
118
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
119
|
+
attr_accessor :ssl_ca_cert
|
120
|
+
|
121
|
+
### TLS/SSL setting
|
122
|
+
# Client certificate file (for client certificate)
|
123
|
+
attr_accessor :cert_file
|
124
|
+
|
125
|
+
### TLS/SSL setting
|
126
|
+
# Client private key file (for client certificate)
|
127
|
+
attr_accessor :key_file
|
128
|
+
|
129
|
+
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
130
|
+
# Default to nil.
|
131
|
+
#
|
132
|
+
# @see The params_encoding option of Ethon. Related source code:
|
133
|
+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
134
|
+
attr_accessor :params_encoding
|
135
|
+
|
136
|
+
attr_accessor :inject_format
|
137
|
+
|
138
|
+
attr_accessor :force_ending_format
|
139
|
+
|
140
|
+
def initialize
|
141
|
+
@scheme = 'https'
|
142
|
+
@host = 'connect.primary.health'
|
143
|
+
@base_path = ''
|
144
|
+
@server_index = 0
|
145
|
+
@server_operation_index = {}
|
146
|
+
@server_variables = {}
|
147
|
+
@server_operation_variables = {}
|
148
|
+
@api_key = {}
|
149
|
+
@api_key_prefix = {}
|
150
|
+
@timeout = 0
|
151
|
+
@client_side_validation = true
|
152
|
+
@verify_ssl = true
|
153
|
+
@verify_ssl_host = true
|
154
|
+
@params_encoding = nil
|
155
|
+
@cert_file = nil
|
156
|
+
@key_file = nil
|
157
|
+
@debugging = false
|
158
|
+
@inject_format = false
|
159
|
+
@force_ending_format = false
|
160
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
161
|
+
|
162
|
+
yield(self) if block_given?
|
163
|
+
end
|
164
|
+
|
165
|
+
# The default Configuration object.
|
166
|
+
def self.default
|
167
|
+
@@default ||= Configuration.new
|
168
|
+
end
|
169
|
+
|
170
|
+
def configure
|
171
|
+
yield(self) if block_given?
|
172
|
+
end
|
173
|
+
|
174
|
+
def scheme=(scheme)
|
175
|
+
# remove :// from scheme
|
176
|
+
@scheme = scheme.sub(/:\/\//, '')
|
177
|
+
end
|
178
|
+
|
179
|
+
def host=(host)
|
180
|
+
# remove http(s):// and anything after a slash
|
181
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
182
|
+
end
|
183
|
+
|
184
|
+
def base_path=(base_path)
|
185
|
+
# Add leading and trailing slashes to base_path
|
186
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
187
|
+
@base_path = '' if @base_path == '/'
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns base URL for specified operation based on server settings
|
191
|
+
def base_url(operation = nil)
|
192
|
+
index = server_operation_index.fetch(operation, server_index)
|
193
|
+
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
|
194
|
+
|
195
|
+
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
196
|
+
end
|
197
|
+
|
198
|
+
# Gets API key (with prefix if set).
|
199
|
+
# @param [String] param_name the parameter name of API key auth
|
200
|
+
def api_key_with_prefix(param_name, param_alias = nil)
|
201
|
+
key = @api_key[param_name]
|
202
|
+
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
|
203
|
+
if @api_key_prefix[param_name]
|
204
|
+
"#{@api_key_prefix[param_name]} #{key}"
|
205
|
+
else
|
206
|
+
key
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
# Gets Basic Auth token string
|
211
|
+
def basic_auth_token
|
212
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
213
|
+
end
|
214
|
+
|
215
|
+
# Returns Auth Settings hash for api client.
|
216
|
+
def auth_settings
|
217
|
+
{
|
218
|
+
'bearer_auth' =>
|
219
|
+
{
|
220
|
+
type: 'bearer',
|
221
|
+
in: 'header',
|
222
|
+
key: 'Authorization',
|
223
|
+
value: "Bearer #{access_token}"
|
224
|
+
},
|
225
|
+
}
|
226
|
+
end
|
227
|
+
|
228
|
+
# Returns an array of Server setting
|
229
|
+
def server_settings
|
230
|
+
[
|
231
|
+
{
|
232
|
+
url: "https://{defaultHost}",
|
233
|
+
description: "Production",
|
234
|
+
variables: {
|
235
|
+
defaultHost: {
|
236
|
+
description: "No description provided",
|
237
|
+
default_value: "connect.primary.health",
|
238
|
+
}
|
239
|
+
}
|
240
|
+
},
|
241
|
+
{
|
242
|
+
url: "https://{defaultHost}",
|
243
|
+
description: "Staging",
|
244
|
+
variables: {
|
245
|
+
defaultHost: {
|
246
|
+
description: "No description provided",
|
247
|
+
default_value: "connect-staging.primary.health",
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
]
|
252
|
+
end
|
253
|
+
|
254
|
+
def operation_server_settings
|
255
|
+
{
|
256
|
+
}
|
257
|
+
end
|
258
|
+
|
259
|
+
# Returns URL based on server settings
|
260
|
+
#
|
261
|
+
# @param index array index of the server settings
|
262
|
+
# @param variables hash of variable and the corresponding value
|
263
|
+
def server_url(index, variables = {}, servers = nil)
|
264
|
+
servers = server_settings if servers == nil
|
265
|
+
|
266
|
+
# check array index out of bound
|
267
|
+
if (index < 0 || index >= servers.size)
|
268
|
+
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
269
|
+
end
|
270
|
+
|
271
|
+
server = servers[index]
|
272
|
+
url = server[:url]
|
273
|
+
|
274
|
+
return url unless server.key? :variables
|
275
|
+
|
276
|
+
# go through variable and assign a value
|
277
|
+
server[:variables].each do |name, variable|
|
278
|
+
if variables.key?(name)
|
279
|
+
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
|
280
|
+
url.gsub! "{" + name.to_s + "}", variables[name]
|
281
|
+
else
|
282
|
+
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
283
|
+
end
|
284
|
+
else
|
285
|
+
# use default value
|
286
|
+
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
url
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
=begin
|
2
|
+
#Primary Connect API V1
|
3
|
+
|
4
|
+
#Client Library to interface with Primary Connect
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
# Common files
|
11
|
+
require 'primary_connect_client/api_client'
|
12
|
+
require 'primary_connect_client/api_error'
|
13
|
+
require 'primary_connect_client/version'
|
14
|
+
require 'primary_connect_client/configuration'
|
15
|
+
|
16
|
+
# APIs
|
17
|
+
require 'primary_connect_client/api/default_api'
|
18
|
+
|
19
|
+
# Protobufs
|
20
|
+
require 'primary_connect_proto'
|
21
|
+
|
22
|
+
module PrimaryConnectClient
|
23
|
+
class << self
|
24
|
+
# Customize default settings for the SDK using block.
|
25
|
+
# PrimaryConnectClient.configure do |config|
|
26
|
+
# config.username = "xxx"
|
27
|
+
# config.password = "xxx"
|
28
|
+
# end
|
29
|
+
# If no block given, return the default Configuration object.
|
30
|
+
def configure
|
31
|
+
if block_given?
|
32
|
+
yield(Configuration.default)
|
33
|
+
else
|
34
|
+
Configuration.default
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# -*- encoding: utf-8 -*-
|
4
|
+
|
5
|
+
=begin
|
6
|
+
#Primary Connect API V1
|
7
|
+
|
8
|
+
#Client Library to interface with Primary Connect
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
$:.push File.expand_path("../lib", __FILE__)
|
13
|
+
require "primary_connect_client/version"
|
14
|
+
|
15
|
+
Gem::Specification.new do |s|
|
16
|
+
s.name = "primary_connect_client"
|
17
|
+
s.version = PrimaryConnectClient::VERSION
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.authors = [""]
|
20
|
+
s.email = [""]
|
21
|
+
s.homepage = "https://openapi-generator.tech"
|
22
|
+
s.summary = "Primary Connect API V1 Ruby Gem"
|
23
|
+
s.description = "Client Library to interface with Primary Connect"
|
24
|
+
s.license = "Unlicense"
|
25
|
+
s.required_ruby_version = ">= 2.4"
|
26
|
+
|
27
|
+
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
28
|
+
s.add_runtime_dependency 'primary_connect_proto', '~> 0.5.0'
|
29
|
+
|
30
|
+
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
31
|
+
|
32
|
+
s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
|
33
|
+
s.test_files = `find spec/*`.split("\n")
|
34
|
+
s.executables = []
|
35
|
+
s.require_paths = ["lib", "lib/protobuf/build"]
|
36
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
=begin
|
2
|
+
#API V1
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.2.1-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for PrimaryConnectClient::DefaultApi
|
17
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'DefaultApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = PrimaryConnectClient::DefaultApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of DefaultApi' do
|
30
|
+
it 'should create an instance of DefaultApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(PrimaryConnectClient::DefaultApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for api_v1_events_get
|
36
|
+
# list events
|
37
|
+
# @param [Hash] opts the optional parameters
|
38
|
+
# @option opts [String] :last_event_id
|
39
|
+
# @option opts [String] :event_types
|
40
|
+
# @return [nil]
|
41
|
+
describe 'api_v1_events_get test' do
|
42
|
+
it 'should work' do
|
43
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# unit tests for api_v1_messages_get
|
48
|
+
# list messages
|
49
|
+
# @param [Hash] opts the optional parameters
|
50
|
+
# @return [Array<Message>]
|
51
|
+
describe 'api_v1_messages_get test' do
|
52
|
+
it 'should work' do
|
53
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# unit tests for api_v1_orders_get
|
58
|
+
# list orders
|
59
|
+
# @param [Hash] opts the optional parameters
|
60
|
+
# @return [nil]
|
61
|
+
describe 'api_v1_orders_get test' do
|
62
|
+
it 'should work' do
|
63
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# unit tests for api_v1_orders_id_get
|
68
|
+
# show order
|
69
|
+
# @param id id
|
70
|
+
# @param [Hash] opts the optional parameters
|
71
|
+
# @return [nil]
|
72
|
+
describe 'api_v1_orders_id_get test' do
|
73
|
+
it 'should work' do
|
74
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# unit tests for api_v1_orders_order_id_results_get
|
79
|
+
# list results
|
80
|
+
# @param order_id Order id
|
81
|
+
# @param [Hash] opts the optional parameters
|
82
|
+
# @return [nil]
|
83
|
+
describe 'api_v1_orders_order_id_results_get test' do
|
84
|
+
it 'should work' do
|
85
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# unit tests for api_v1_orders_order_id_results_id_get
|
90
|
+
# show result
|
91
|
+
# @param order_id Order id
|
92
|
+
# @param id id
|
93
|
+
# @param [Hash] opts the optional parameters
|
94
|
+
# @return [nil]
|
95
|
+
describe 'api_v1_orders_order_id_results_id_get test' do
|
96
|
+
it 'should work' do
|
97
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# unit tests for api_v1_orders_post
|
102
|
+
# create order
|
103
|
+
# @param [Hash] opts the optional parameters
|
104
|
+
# @option opts [Order] :order
|
105
|
+
# @return [nil]
|
106
|
+
describe 'api_v1_orders_post test' do
|
107
|
+
it 'should work' do
|
108
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|