qpruvcheig 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +133 -0
- data/lib/qpruvcheig.rb +36 -0
- data/lib/qpruvcheig/api_helper.rb +275 -0
- data/lib/qpruvcheig/configuration.rb +76 -0
- data/lib/qpruvcheig/controllers/api_controller.rb +40 -0
- data/lib/qpruvcheig/controllers/base_controller.rb +51 -0
- data/lib/qpruvcheig/exceptions/api_exception.rb +20 -0
- data/lib/qpruvcheig/http/auth/basic_auth.rb +22 -0
- data/lib/qpruvcheig/http/faraday_client.rb +62 -0
- data/lib/qpruvcheig/http/http_call_back.rb +24 -0
- data/lib/qpruvcheig/http/http_client.rb +104 -0
- data/lib/qpruvcheig/http/http_context.rb +20 -0
- data/lib/qpruvcheig/http/http_method_enum.rb +13 -0
- data/lib/qpruvcheig/http/http_request.rb +50 -0
- data/lib/qpruvcheig/http/http_response.rb +23 -0
- data/lib/qpruvcheig/models/base_model.rb +36 -0
- data/lib/qpruvcheig/models/suite_code_enum.rb +23 -0
- data/lib/qpruvcheig/qpruvcheig_client.rb +29 -0
- data/test/controllers/controller_test_base.rb +36 -0
- data/test/controllers/test_api_controller.rb +28 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/test_helper.rb +94 -0
- metadata +148 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# qpruvcheig
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Qpruvcheig
|
7
|
+
# Http response received.
|
8
|
+
class HttpResponse
|
9
|
+
attr_accessor :status_code, :headers, :raw_body
|
10
|
+
|
11
|
+
# The constructor
|
12
|
+
# @param [Integer] The status code returned by the server.
|
13
|
+
# @param [Hash] The headers sent by the server in the response.
|
14
|
+
# @param [String] The raw body of the response.
|
15
|
+
def initialize(status_code,
|
16
|
+
headers,
|
17
|
+
raw_body)
|
18
|
+
@status_code = status_code
|
19
|
+
@headers = headers
|
20
|
+
@raw_body = raw_body
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# qpruvcheig
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Qpruvcheig
|
7
|
+
# Base model.
|
8
|
+
class BaseModel
|
9
|
+
# Returns a Hash representation of the current object.
|
10
|
+
def to_hash
|
11
|
+
hash = {}
|
12
|
+
instance_variables.each do |name|
|
13
|
+
value = instance_variable_get(name)
|
14
|
+
name = name[1..-1]
|
15
|
+
key = self.class.names.key?(name) ? self.class.names[name] : name
|
16
|
+
if value.instance_of? Array
|
17
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
18
|
+
elsif value.instance_of? Hash
|
19
|
+
hash[key] = {}
|
20
|
+
value.each do |k, v|
|
21
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
22
|
+
end
|
23
|
+
else
|
24
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
hash
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns a JSON representation of the curent object.
|
31
|
+
def to_json(options = {})
|
32
|
+
hash = to_hash
|
33
|
+
hash.to_json(options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# qpruvcheig
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Qpruvcheig
|
7
|
+
# A integer based enum representing a Suite in a game of cards
|
8
|
+
class SuiteCodeEnum
|
9
|
+
SUITE_CODE_ENUM = [
|
10
|
+
# TODO: Write general description for HEARTS
|
11
|
+
HEARTS = 1,
|
12
|
+
|
13
|
+
# TODO: Write general description for SPADES
|
14
|
+
SPADES = 2,
|
15
|
+
|
16
|
+
# TODO: Write general description for CLUBS
|
17
|
+
CLUBS = 3,
|
18
|
+
|
19
|
+
# TODO: Write general description for DIAMONDS
|
20
|
+
DIAMONDS = 4
|
21
|
+
].freeze
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# qpruvcheig
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Qpruvcheig
|
7
|
+
# qpruvcheig client class.
|
8
|
+
class QpruvcheigClient
|
9
|
+
# Singleton access to client controller.
|
10
|
+
# @return [APIController] Returns the controller instance.
|
11
|
+
def client
|
12
|
+
APIController.instance
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns the configuration class for easy access.
|
16
|
+
# @return [Configuration] Returns the actual configuration class.
|
17
|
+
def config
|
18
|
+
Configuration
|
19
|
+
end
|
20
|
+
|
21
|
+
# Initializer with authentication and configuration parameters.
|
22
|
+
def initialize(basic_auth_user_name: nil, basic_auth_password: nil)
|
23
|
+
Configuration.basic_auth_user_name = basic_auth_user_name if
|
24
|
+
basic_auth_user_name
|
25
|
+
Configuration.basic_auth_password = basic_auth_password if
|
26
|
+
basic_auth_password
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# qpruvcheig
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'json'
|
7
|
+
require 'test/unit'
|
8
|
+
require 'qpruvcheig.rb'
|
9
|
+
require_relative '../test_helper.rb'
|
10
|
+
require_relative '../http_response_catcher.rb'
|
11
|
+
|
12
|
+
class ControllerTestBase < Test::Unit::TestCase
|
13
|
+
include Qpruvcheig
|
14
|
+
|
15
|
+
class << self
|
16
|
+
attr_accessor :controller
|
17
|
+
end
|
18
|
+
|
19
|
+
# Called only once for a test class before any test has executed.
|
20
|
+
def self.startup
|
21
|
+
@@api_client = QpruvcheigClient.new
|
22
|
+
@@request_timeout = 100
|
23
|
+
@@assert_precision = 0.01
|
24
|
+
|
25
|
+
# Set Configuration parameters for test execution
|
26
|
+
Configuration.basic_auth_user_name = 'Zeeshan'
|
27
|
+
Configuration.basic_auth_password = 'bhai_99'
|
28
|
+
Configuration.environment = Configuration::Environment::TESTING
|
29
|
+
end
|
30
|
+
|
31
|
+
# Called once before every test case.
|
32
|
+
def setup
|
33
|
+
@response_catcher = HttpResponseCatcher.new
|
34
|
+
self.class.controller.http_call_back = @response_catcher
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# qpruvcheig
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require_relative 'controller_test_base'
|
7
|
+
|
8
|
+
class APIControllerTests < ControllerTestBase
|
9
|
+
# Called only once for the class before any test has executed
|
10
|
+
def self.startup
|
11
|
+
self.controller = @@api_client.client
|
12
|
+
end
|
13
|
+
|
14
|
+
# Todo: Add description for test test_basic_auth_test
|
15
|
+
def test_basic_auth_test()
|
16
|
+
|
17
|
+
# Perform the API call through the SDK function
|
18
|
+
result = self.class.controller.get_basic_auth_test()
|
19
|
+
|
20
|
+
# Test response code
|
21
|
+
assert_equal(@response_catcher.response.status_code, 200)
|
22
|
+
|
23
|
+
# Test whether the captured response is as we expected
|
24
|
+
assert_not_nil(result)
|
25
|
+
assert_equal('You\'ve passed the test!', @response_catcher.response.raw_body)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# qpruvcheig
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
class HttpResponseCatcher < Qpruvcheig::HttpCallBack
|
7
|
+
attr_accessor :response
|
8
|
+
|
9
|
+
def on_before_request(request)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Catching the response
|
13
|
+
def on_after_response(context)
|
14
|
+
@response = context.response
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# qpruvcheig
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'tempfile'
|
7
|
+
require 'open-uri'
|
8
|
+
|
9
|
+
class TestHelper
|
10
|
+
|
11
|
+
@cache = Hash.new
|
12
|
+
|
13
|
+
# Class method to compare the received headers with the expected headers.
|
14
|
+
# @param [Hash] A hash of expected headers (keys in lower case).
|
15
|
+
# @param [Hash] A hash of received headers.
|
16
|
+
# @param [Boolean, optional] A flag which determines if we allow extra headers.
|
17
|
+
def self.match_headers(expected_headers,
|
18
|
+
received_headers,
|
19
|
+
allow_extra: true)
|
20
|
+
return false if ((received_headers.length < expected_headers.length) ||
|
21
|
+
((allow_extra == false) && (received_headers.length > expected_headers.length)))
|
22
|
+
|
23
|
+
received_headers = Hash[received_headers.map{|k, v| [k.to_s.downcase, v]}]
|
24
|
+
expected_headers.each do |e_key, e_value|
|
25
|
+
return false unless received_headers.key?(e_key)
|
26
|
+
return false if ((e_value != nil) &&
|
27
|
+
(e_value != received_headers[e_key]))
|
28
|
+
end
|
29
|
+
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
|
33
|
+
# Class method to compare the received body with the expected body.
|
34
|
+
# @param [Dynamic] The expected body.
|
35
|
+
# @param [Dynamic] The received body.
|
36
|
+
# @param [Boolean, optional] A flag which determines if we check values in dictionaries.
|
37
|
+
# @param [Boolean, optional] A flag which determines if we check the order of array elements.
|
38
|
+
# @param [Boolean, optional] A flag which determines if we check the count of array elements.
|
39
|
+
def self.match_body(expected_body,
|
40
|
+
received_body,
|
41
|
+
check_values: false,
|
42
|
+
check_order: false,
|
43
|
+
check_count: false)
|
44
|
+
if expected_body.instance_of? Hash
|
45
|
+
return false unless received_body.instance_of? Hash
|
46
|
+
for key in expected_body.keys
|
47
|
+
return false unless received_body.keys.include? key
|
48
|
+
if check_values or expected_body[key].instance_of? Hash
|
49
|
+
return false unless TestHelper.match_body(expected_body[key],
|
50
|
+
received_body[key],
|
51
|
+
check_values: check_values,
|
52
|
+
check_order: check_order,
|
53
|
+
check_count: check_count)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
elsif expected_body.instance_of? Array
|
57
|
+
return False unless received_body.instance_of? Array
|
58
|
+
if check_count == true && (expected_body.length != received_body.length)
|
59
|
+
return false
|
60
|
+
else
|
61
|
+
previous_matches = Array.new
|
62
|
+
expected_body.each.with_index do |expected_element, i|
|
63
|
+
matches = (received_body.map.with_index do |received_element, j|
|
64
|
+
j if TestHelper.match_body(expected_element,
|
65
|
+
received_element,
|
66
|
+
check_values: check_values,
|
67
|
+
check_order: check_order,
|
68
|
+
check_count: check_count)
|
69
|
+
end).compact
|
70
|
+
return false if matches.length == 0
|
71
|
+
if check_order == true
|
72
|
+
return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?)
|
73
|
+
previous_matches = matches
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
elsif expected_body != received_body
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Class method which takes a URL, downloads the file (if not already downloaded
|
84
|
+
# for this test session) and returns the path of the file.
|
85
|
+
# @param [String] The URL of the required file.
|
86
|
+
def self.get_file(url)
|
87
|
+
unless @cache.keys.include? url
|
88
|
+
@cache[url] = Tempfile.new('APIMatic')
|
89
|
+
@cache[url].binmode
|
90
|
+
@cache[url].write(open(url, {ssl_ca_cert: Certifi.where}).read)
|
91
|
+
end
|
92
|
+
return @cache[url].path
|
93
|
+
end
|
94
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qpruvcheig
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- APIMatic SDK Generator
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logging
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.10.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.10.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.5
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.5
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: certifi
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2016.9'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2016.09.26
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '2016.9'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2016.09.26
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: faraday-http-cache
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.2'
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.2.2
|
85
|
+
type: :runtime
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.2'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.2.2
|
95
|
+
description: ''
|
96
|
+
email: support@apimatic.io
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- LICENSE
|
102
|
+
- README.md
|
103
|
+
- lib/qpruvcheig.rb
|
104
|
+
- lib/qpruvcheig/api_helper.rb
|
105
|
+
- lib/qpruvcheig/configuration.rb
|
106
|
+
- lib/qpruvcheig/controllers/api_controller.rb
|
107
|
+
- lib/qpruvcheig/controllers/base_controller.rb
|
108
|
+
- lib/qpruvcheig/exceptions/api_exception.rb
|
109
|
+
- lib/qpruvcheig/http/auth/basic_auth.rb
|
110
|
+
- lib/qpruvcheig/http/faraday_client.rb
|
111
|
+
- lib/qpruvcheig/http/http_call_back.rb
|
112
|
+
- lib/qpruvcheig/http/http_client.rb
|
113
|
+
- lib/qpruvcheig/http/http_context.rb
|
114
|
+
- lib/qpruvcheig/http/http_method_enum.rb
|
115
|
+
- lib/qpruvcheig/http/http_request.rb
|
116
|
+
- lib/qpruvcheig/http/http_response.rb
|
117
|
+
- lib/qpruvcheig/models/base_model.rb
|
118
|
+
- lib/qpruvcheig/models/suite_code_enum.rb
|
119
|
+
- lib/qpruvcheig/qpruvcheig_client.rb
|
120
|
+
- test/controllers/controller_test_base.rb
|
121
|
+
- test/controllers/test_api_controller.rb
|
122
|
+
- test/http_response_catcher.rb
|
123
|
+
- test/test_helper.rb
|
124
|
+
homepage: https://apimatic.io
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '2.0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.7.5
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: qpruvcheig
|
148
|
+
test_files: []
|