devme-sdk-ruby 1.0.2
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 +7 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +71 -0
- data/LICENSE.md +25 -0
- data/README.md +97 -0
- data/Rakefile +10 -0
- data/devme-sdk-ruby.gemspec +38 -0
- data/examples/app/.gitignore +198 -0
- data/examples/app/Gemfile +6 -0
- data/examples/app/Gemfile.lock +23 -0
- data/examples/app/test-api.rb +20 -0
- data/lib/devme-sdk-ruby/api/country_api.rb +178 -0
- data/lib/devme-sdk-ruby/api/currency_api.rb +333 -0
- data/lib/devme-sdk-ruby/api/domain_api.rb +81 -0
- data/lib/devme-sdk-ruby/api/email_api.rb +91 -0
- data/lib/devme-sdk-ruby/api/ip_api.rb +81 -0
- data/lib/devme-sdk-ruby/api/phone_api.rb +85 -0
- data/lib/devme-sdk-ruby/api/utils_api.rb +78 -0
- data/lib/devme-sdk-ruby/api_client.rb +390 -0
- data/lib/devme-sdk-ruby/api_error.rb +57 -0
- data/lib/devme-sdk-ruby/configuration.rb +285 -0
- data/lib/devme-sdk-ruby/models/convert_currency_out.rb +280 -0
- data/lib/devme-sdk-ruby/models/error.rb +251 -0
- data/lib/devme-sdk-ruby/models/get_country_details_out.rb +230 -0
- data/lib/devme-sdk-ruby/models/get_currency_details_out.rb +230 -0
- data/lib/devme-sdk-ruby/models/get_currency_exchange_rate_out.rb +250 -0
- data/lib/devme-sdk-ruby/models/get_domain_whois_out.rb +230 -0
- data/lib/devme-sdk-ruby/models/get_email_details_out.rb +290 -0
- data/lib/devme-sdk-ruby/models/get_ip_details_city_out.rb +260 -0
- data/lib/devme-sdk-ruby/models/get_ip_details_out.rb +269 -0
- data/lib/devme-sdk-ruby/models/get_phone_details_out.rb +270 -0
- data/lib/devme-sdk-ruby/models/http_error_out.rb +252 -0
- data/lib/devme-sdk-ruby/models/list_countries_item.rb +230 -0
- data/lib/devme-sdk-ruby/models/list_countries_out.rb +242 -0
- data/lib/devme-sdk-ruby/models/list_currencies_item.rb +314 -0
- data/lib/devme-sdk-ruby/models/list_currencies_out.rb +242 -0
- data/lib/devme-sdk-ruby/models/who_am_i_out.rb +264 -0
- data/lib/devme-sdk-ruby/version.rb +15 -0
- data/lib/devme-sdk-ruby.rb +62 -0
- data/spec/api/country_api_spec.rb +66 -0
- data/spec/api/currency_api_spec.rb +101 -0
- data/spec/api/domain_api_spec.rb +46 -0
- data/spec/api/email_api_spec.rb +48 -0
- data/spec/api/ip_api_spec.rb +53 -0
- data/spec/api/phone_api_spec.rb +46 -0
- data/spec/api/utils_api_spec.rb +45 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/spec_helper.rb +111 -0
- metadata +146 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
=begin
|
2
|
+
#DEV.ME API Documentation
|
3
|
+
|
4
|
+
#DEV.ME API Documentation [Currency Conversion and Exchange Rates API](https://dev.me/products/currency) - [IP2Location, IP Country, IP Information API](https://dev.me/products/ip) - [Email Validation, Mailbox Verification](https://dev.me/products/email) - [Phone Number Validation](https://dev.me/products/phone). You can learn more at [dev.me](https://dev.me). For this example you can use api key `demo-key` to test the APIs
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@dev.me
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for DevmeSdk::CurrencyApi
|
17
|
+
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'CurrencyApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
DevmeSdk.configure do |config|
|
23
|
+
config.api_key['APIKeyHeader'] = 'demo-key'
|
24
|
+
end
|
25
|
+
@api_instance = DevmeSdk::CurrencyApi.new
|
26
|
+
end
|
27
|
+
|
28
|
+
after do
|
29
|
+
# run after each test
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'test an instance of CurrencyApi' do
|
33
|
+
it 'should create an instance of CurrencyApi' do
|
34
|
+
expect(@api_instance).to be_instance_of(DevmeSdk::CurrencyApi)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# unit tests for v1_convert_currency
|
39
|
+
# Convert currency to another currency
|
40
|
+
# @param from from - currency to convert from
|
41
|
+
# @param to to - currency to convert to
|
42
|
+
# @param [Hash] opts the optional parameters
|
43
|
+
# @option opts [Float] :amount amount - amount to convert
|
44
|
+
# @return [ConvertCurrencyOut]
|
45
|
+
describe 'v1_convert_currency test' do
|
46
|
+
it 'should work' do
|
47
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
48
|
+
result = @api_instance.v1_convert_currency(from = 'USD', to = 'EUR', opts = { amount: 10 })
|
49
|
+
expect(result).to be_instance_of(DevmeSdk::ConvertCurrencyOut)
|
50
|
+
expect(result.to).to eq('EUR')
|
51
|
+
expect(result.from).to eq('USD')
|
52
|
+
expect(result.converted_amount).to be_within(1).of(8.0)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# unit tests for v1_get_currency_details
|
57
|
+
# Get currency facts and information
|
58
|
+
# @param code code - currency code ISO 4217
|
59
|
+
# @param [Hash] opts the optional parameters
|
60
|
+
# @option opts [Array<String>] :expand expand - expand properties
|
61
|
+
# @option opts [Array<String>] :exclude exclude - exclude properties
|
62
|
+
# @option opts [String] :language language - localisation language
|
63
|
+
# @option opts [String] :type type - type of currency
|
64
|
+
# @return [GetCurrencyDetailsOut]
|
65
|
+
describe 'v1_get_currency_details test' do
|
66
|
+
it 'should work' do
|
67
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# unit tests for v1_get_currency_exchange_rate
|
72
|
+
# Get exchange rate for a currency
|
73
|
+
# @param from from - currency to get exchange rate from
|
74
|
+
# @param to to - currency to get exchange rate to
|
75
|
+
# @param [Hash] opts the optional parameters
|
76
|
+
# @return [GetCurrencyExchangeRateOut]
|
77
|
+
describe 'v1_get_currency_exchange_rate test' do
|
78
|
+
it 'should work' do
|
79
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# unit tests for v1_list_currencies
|
84
|
+
# Get list of all currencies
|
85
|
+
# @param [Hash] opts the optional parameters
|
86
|
+
# @option opts [Array<String>] :code code - currency code ISO 4217
|
87
|
+
# @option opts [Array<String>] :expand expand - expand properties
|
88
|
+
# @option opts [Array<String>] :exclude exclude - exclude properties
|
89
|
+
# @option opts [String] :language language - localisation language
|
90
|
+
# @option opts [String] :type type - type of currency
|
91
|
+
# @option opts [Array<String>] :sort sort - sort properties
|
92
|
+
# @option opts [String] :page page - page number
|
93
|
+
# @option opts [String] :page_size pageSize - page size
|
94
|
+
# @return [ListCurrenciesOut]
|
95
|
+
describe 'v1_list_currencies 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
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
=begin
|
2
|
+
#DEV.ME API Documentation
|
3
|
+
|
4
|
+
#DEV.ME API Documentation [Currency Conversion and Exchange Rates API](https://dev.me/products/currency) - [IP2Location, IP Country, IP Information API](https://dev.me/products/ip) - [Email Validation, Mailbox Verification](https://dev.me/products/email) - [Phone Number Validation](https://dev.me/products/phone). You can learn more at [dev.me](https://dev.me). For this example you can use api key `demo-key` to test the APIs
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@dev.me
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for DevmeSdk::DomainApi
|
17
|
+
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'DomainApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = DevmeSdk::DomainApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of DomainApi' do
|
30
|
+
it 'should create an instance of DomainApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(DevmeSdk::DomainApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for v1_get_domain_whois
|
36
|
+
# Get domain WHOIS details and registration information
|
37
|
+
# @param [Hash] opts the optional parameters
|
38
|
+
# @option opts [String] :domain domain - Domain name to get details for
|
39
|
+
# @return [GetDomainWhoisOut]
|
40
|
+
describe 'v1_get_domain_whois test' do
|
41
|
+
it 'should work' do
|
42
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
=begin
|
2
|
+
#DEV.ME API Documentation
|
3
|
+
|
4
|
+
#DEV.ME API Documentation [Currency Conversion and Exchange Rates API](https://dev.me/products/currency) - [IP2Location, IP Country, IP Information API](https://dev.me/products/ip) - [Email Validation, Mailbox Verification](https://dev.me/products/email) - [Phone Number Validation](https://dev.me/products/phone). You can learn more at [dev.me](https://dev.me). For this example you can use api key `demo-key` to test the APIs
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@dev.me
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for DevmeSdk::EmailApi
|
17
|
+
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'EmailApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = DevmeSdk::EmailApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of EmailApi' do
|
30
|
+
it 'should create an instance of EmailApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(DevmeSdk::EmailApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for v1_get_email_details
|
36
|
+
# Get email validation details
|
37
|
+
# @param email email - email address
|
38
|
+
# @param [Hash] opts the optional parameters
|
39
|
+
# @option opts [Boolean] :verify_mx verifyMx - verify domain dns for MX record
|
40
|
+
# @option opts [Boolean] :verify_smtp verifySmtp - verify mailbox with SMTP Connect and Reply
|
41
|
+
# @return [GetEmailDetailsOut]
|
42
|
+
describe 'v1_get_email_details test' do
|
43
|
+
it 'should work' do
|
44
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
=begin
|
2
|
+
#DEV.ME API Documentation
|
3
|
+
|
4
|
+
#DEV.ME API Documentation [Currency Conversion and Exchange Rates API](https://dev.me/products/currency) - [IP2Location, IP Country, IP Information API](https://dev.me/products/ip) - [Email Validation, Mailbox Verification](https://dev.me/products/email) - [Phone Number Validation](https://dev.me/products/phone). You can learn more at [dev.me](https://dev.me). For this example you can use api key `demo-key` to test the APIs
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@dev.me
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for DevmeSdk::IPApi
|
17
|
+
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'IPApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
DevmeSdk.configure do |config|
|
23
|
+
config.api_key['APIKeyHeader'] = 'demo-key'
|
24
|
+
end
|
25
|
+
@api_instance = DevmeSdk::IPApi.new
|
26
|
+
end
|
27
|
+
|
28
|
+
after do
|
29
|
+
# run after each test
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'test an instance of IPApi' do
|
33
|
+
it 'should create an instance of IPApi' do
|
34
|
+
expect(@api_instance).to be_instance_of(DevmeSdk::IPApi)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# unit tests for v1_get_ip_details
|
39
|
+
# Get IP GEO Location and ISP details
|
40
|
+
# @param [Hash] opts the optional parameters
|
41
|
+
# @option opts [String] :ip ip - IP Address
|
42
|
+
# @return [GetIpDetailsOut]
|
43
|
+
describe 'v1_get_ip_details test' do
|
44
|
+
it 'should work' do
|
45
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
46
|
+
result = @api_instance.v1_get_ip_details(opts = { ip: '52.45.23.11' })
|
47
|
+
expect(result.ip).to eq('52.45.23.11')
|
48
|
+
expect(result.country_code).to eq('US')
|
49
|
+
expect(result.aso).to eq('AMAZON-AES')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
=begin
|
2
|
+
#DEV.ME API Documentation
|
3
|
+
|
4
|
+
#DEV.ME API Documentation [Currency Conversion and Exchange Rates API](https://dev.me/products/currency) - [IP2Location, IP Country, IP Information API](https://dev.me/products/ip) - [Email Validation, Mailbox Verification](https://dev.me/products/email) - [Phone Number Validation](https://dev.me/products/phone). You can learn more at [dev.me](https://dev.me). For this example you can use api key `demo-key` to test the APIs
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@dev.me
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for DevmeSdk::PhoneApi
|
17
|
+
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'PhoneApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = DevmeSdk::PhoneApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of PhoneApi' do
|
30
|
+
it 'should create an instance of PhoneApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(DevmeSdk::PhoneApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for v1_get_phone_details
|
36
|
+
# Get phone validation details
|
37
|
+
# @param phone phone - phone number to validate
|
38
|
+
# @param [Hash] opts the optional parameters
|
39
|
+
# @return [GetPhoneDetailsOut]
|
40
|
+
describe 'v1_get_phone_details test' do
|
41
|
+
it 'should work' do
|
42
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
=begin
|
2
|
+
#DEV.ME API Documentation
|
3
|
+
|
4
|
+
#DEV.ME API Documentation [Currency Conversion and Exchange Rates API](https://dev.me/products/currency) - [IP2Location, IP Country, IP Information API](https://dev.me/products/ip) - [Email Validation, Mailbox Verification](https://dev.me/products/email) - [Phone Number Validation](https://dev.me/products/phone). You can learn more at [dev.me](https://dev.me). For this example you can use api key `demo-key` to test the APIs
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@dev.me
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for DevmeSdk::UtilsApi
|
17
|
+
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'UtilsApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = DevmeSdk::UtilsApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of UtilsApi' do
|
30
|
+
it 'should create an instance of UtilsApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(DevmeSdk::UtilsApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for v1_who_am_i
|
36
|
+
# Get current user details with api key
|
37
|
+
# @param [Hash] opts the optional parameters
|
38
|
+
# @return [WhoAmIOut]
|
39
|
+
describe 'v1_who_am_i test' do
|
40
|
+
it 'should work' do
|
41
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
=begin
|
2
|
+
#DEV.ME API Documentation
|
3
|
+
|
4
|
+
#DEV.ME API Documentation [Currency Conversion and Exchange Rates API](https://dev.me/products/currency) - [IP2Location, IP Country, IP Information API](https://dev.me/products/ip) - [Email Validation, Mailbox Verification](https://dev.me/products/email) - [Phone Number Validation](https://dev.me/products/phone). You can learn more at [dev.me](https://dev.me). For this example you can use api key `demo-key` to test the APIs
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@dev.me
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
describe DevmeSdk::ApiClient do
|
16
|
+
context 'initialization' do
|
17
|
+
context 'URL stuff' do
|
18
|
+
context 'host' do
|
19
|
+
it 'removes http from host' do
|
20
|
+
DevmeSdk.configure { |c| c.host = 'http://example.com' }
|
21
|
+
expect(DevmeSdk::Configuration.default.host).to eq('example.com')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'removes https from host' do
|
25
|
+
DevmeSdk.configure { |c| c.host = 'https://wookiee.com' }
|
26
|
+
expect(DevmeSdk::ApiClient.default.config.host).to eq('wookiee.com')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'removes trailing path from host' do
|
30
|
+
DevmeSdk.configure { |c| c.host = 'hobo.com/v4' }
|
31
|
+
expect(DevmeSdk::Configuration.default.host).to eq('hobo.com')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'base_path' do
|
36
|
+
it "prepends a slash to base_path" do
|
37
|
+
DevmeSdk.configure { |c| c.base_path = 'v4/dog' }
|
38
|
+
expect(DevmeSdk::Configuration.default.base_path).to eq('/v4/dog')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "doesn't prepend a slash if one is already there" do
|
42
|
+
DevmeSdk.configure { |c| c.base_path = '/v4/dog' }
|
43
|
+
expect(DevmeSdk::Configuration.default.base_path).to eq('/v4/dog')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "ends up as a blank string if nil" do
|
47
|
+
DevmeSdk.configure { |c| c.base_path = nil }
|
48
|
+
expect(DevmeSdk::Configuration.default.base_path).to eq('')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'params_encoding in #build_request' do
|
55
|
+
let(:config) { DevmeSdk::Configuration.new }
|
56
|
+
let(:api_client) { DevmeSdk::ApiClient.new(config) }
|
57
|
+
|
58
|
+
it 'defaults to nil' do
|
59
|
+
expect(DevmeSdk::Configuration.default.params_encoding).to eq(nil)
|
60
|
+
expect(config.params_encoding).to eq(nil)
|
61
|
+
|
62
|
+
request = api_client.build_request(:get, '/test')
|
63
|
+
expect(request.options[:params_encoding]).to eq(nil)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'can be customized' do
|
67
|
+
config.params_encoding = :multi
|
68
|
+
request = api_client.build_request(:get, '/test')
|
69
|
+
expect(request.options[:params_encoding]).to eq(:multi)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'timeout in #build_request' do
|
74
|
+
let(:config) { DevmeSdk::Configuration.new }
|
75
|
+
let(:api_client) { DevmeSdk::ApiClient.new(config) }
|
76
|
+
|
77
|
+
it 'defaults to 0' do
|
78
|
+
expect(DevmeSdk::Configuration.default.timeout).to eq(0)
|
79
|
+
expect(config.timeout).to eq(0)
|
80
|
+
|
81
|
+
request = api_client.build_request(:get, '/test')
|
82
|
+
expect(request.options[:timeout]).to eq(0)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'can be customized' do
|
86
|
+
config.timeout = 100
|
87
|
+
request = api_client.build_request(:get, '/test')
|
88
|
+
expect(request.options[:timeout]).to eq(100)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#deserialize' do
|
93
|
+
it "handles Array<Integer>" do
|
94
|
+
api_client = DevmeSdk::ApiClient.new
|
95
|
+
headers = { 'Content-Type' => 'application/json' }
|
96
|
+
response = double('response', headers: headers, body: '[12, 34]')
|
97
|
+
data = api_client.deserialize(response, 'Array<Integer>')
|
98
|
+
expect(data).to be_instance_of(Array)
|
99
|
+
expect(data).to eq([12, 34])
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'handles Array<Array<Integer>>' do
|
103
|
+
api_client = DevmeSdk::ApiClient.new
|
104
|
+
headers = { 'Content-Type' => 'application/json' }
|
105
|
+
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
106
|
+
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
107
|
+
expect(data).to be_instance_of(Array)
|
108
|
+
expect(data).to eq([[12, 34], [56]])
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'handles Hash<String, String>' do
|
112
|
+
api_client = DevmeSdk::ApiClient.new
|
113
|
+
headers = { 'Content-Type' => 'application/json' }
|
114
|
+
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
115
|
+
data = api_client.deserialize(response, 'Hash<String, String>')
|
116
|
+
expect(data).to be_instance_of(Hash)
|
117
|
+
expect(data).to eq(:message => 'Hello')
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "#object_to_hash" do
|
122
|
+
it 'ignores nils and includes empty arrays' do
|
123
|
+
# uncomment below to test object_to_hash for model
|
124
|
+
# api_client = DevmeSdk::ApiClient.new
|
125
|
+
# _model = DevmeSdk::ModelName.new
|
126
|
+
# update the model attribute below
|
127
|
+
# _model.id = 1
|
128
|
+
# update the expected value (hash) below
|
129
|
+
# expected = {id: 1, name: '', tags: []}
|
130
|
+
# expect(api_client.object_to_hash(_model)).to eq(expected)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#build_collection_param' do
|
135
|
+
let(:param) { ['aa', 'bb', 'cc'] }
|
136
|
+
let(:api_client) { DevmeSdk::ApiClient.new }
|
137
|
+
|
138
|
+
it 'works for csv' do
|
139
|
+
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'works for ssv' do
|
143
|
+
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'works for tsv' do
|
147
|
+
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'works for pipes' do
|
151
|
+
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'works for multi' do
|
155
|
+
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'fails for invalid collection format' do
|
159
|
+
expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#json_mime?' do
|
164
|
+
let(:api_client) { DevmeSdk::ApiClient.new }
|
165
|
+
|
166
|
+
it 'works' do
|
167
|
+
expect(api_client.json_mime?(nil)).to eq false
|
168
|
+
expect(api_client.json_mime?('')).to eq false
|
169
|
+
|
170
|
+
expect(api_client.json_mime?('application/json')).to eq true
|
171
|
+
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
|
172
|
+
expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
|
173
|
+
|
174
|
+
expect(api_client.json_mime?('application/xml')).to eq false
|
175
|
+
expect(api_client.json_mime?('text/plain')).to eq false
|
176
|
+
expect(api_client.json_mime?('application/jsonp')).to eq false
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe '#select_header_accept' do
|
181
|
+
let(:api_client) { DevmeSdk::ApiClient.new }
|
182
|
+
|
183
|
+
it 'works' do
|
184
|
+
expect(api_client.select_header_accept(nil)).to be_nil
|
185
|
+
expect(api_client.select_header_accept([])).to be_nil
|
186
|
+
|
187
|
+
expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
|
188
|
+
expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
189
|
+
expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
190
|
+
|
191
|
+
expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
|
192
|
+
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe '#select_header_content_type' do
|
197
|
+
let(:api_client) { DevmeSdk::ApiClient.new }
|
198
|
+
|
199
|
+
it 'works' do
|
200
|
+
expect(api_client.select_header_content_type(nil)).to be_nil
|
201
|
+
expect(api_client.select_header_content_type([])).to be_nil
|
202
|
+
|
203
|
+
expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
|
204
|
+
expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
205
|
+
expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
206
|
+
expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
|
207
|
+
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe '#sanitize_filename' do
|
212
|
+
let(:api_client) { DevmeSdk::ApiClient.new }
|
213
|
+
|
214
|
+
it 'works' do
|
215
|
+
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
216
|
+
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
217
|
+
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
218
|
+
expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
|
219
|
+
expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
|
220
|
+
expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
|
221
|
+
expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
|
222
|
+
expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
|
223
|
+
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
=begin
|
2
|
+
#DEV.ME API Documentation
|
3
|
+
|
4
|
+
#DEV.ME API Documentation [Currency Conversion and Exchange Rates API](https://dev.me/products/currency) - [IP2Location, IP Country, IP Information API](https://dev.me/products/ip) - [Email Validation, Mailbox Verification](https://dev.me/products/email) - [Phone Number Validation](https://dev.me/products/phone). You can learn more at [dev.me](https://dev.me). For this example you can use api key `demo-key` to test the APIs
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@dev.me
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
describe DevmeSdk::Configuration do
|
16
|
+
let(:config) { DevmeSdk::Configuration.default }
|
17
|
+
|
18
|
+
before(:each) do
|
19
|
+
# uncomment below to setup host and base_path
|
20
|
+
# require 'URI'
|
21
|
+
# uri = URI.parse("https://api.dev.me")
|
22
|
+
# DevmeSdk.configure do |c|
|
23
|
+
# c.host = uri.host
|
24
|
+
# c.base_path = uri.path
|
25
|
+
# end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#base_url' do
|
29
|
+
it 'should have the default value' do
|
30
|
+
# uncomment below to test default value of the base path
|
31
|
+
# expect(config.base_url).to eq("https://api.dev.me")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should remove trailing slashes' do
|
35
|
+
[nil, '', '/', '//'].each do |base_path|
|
36
|
+
config.base_path = base_path
|
37
|
+
# uncomment below to test trailing slashes
|
38
|
+
# expect(config.base_url).to eq("https://api.dev.me")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|