artikcloud 2.0.5 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -1
- data/LICENSE +1 -2
- data/README.md +50 -4
- data/artikcloud.gemspec +29 -5
- data/docs/DeviceTask.md +13 -0
- data/docs/DeviceTaskUpdateRequest.md +8 -0
- data/docs/DeviceTaskUpdateResponse.md +8 -0
- data/docs/DeviceTypeInfo.md +14 -0
- data/docs/DeviceTypeInfoEnvelope.md +8 -0
- data/docs/DeviceTypesApi.md +61 -0
- data/docs/DeviceTypesInfo.md +14 -0
- data/docs/DeviceTypesInfoEnvelope.md +8 -0
- data/docs/DevicesManagementApi.md +870 -0
- data/docs/EventFeedData.md +10 -0
- data/docs/MetadataEnvelope.md +8 -0
- data/docs/MetadataPropertiesEnvelope.md +8 -0
- data/docs/MetadataQueryEnvelope.md +11 -0
- data/docs/MetadataRequest.md +7 -0
- data/docs/Task.md +18 -0
- data/docs/TaskByDid.md +19 -0
- data/docs/TaskByDidList.md +8 -0
- data/docs/TaskByDidListEnvelope.md +11 -0
- data/docs/TaskEnvelope.md +8 -0
- data/docs/TaskHistory.md +13 -0
- data/docs/TaskHistoryList.md +8 -0
- data/docs/TaskList.md +8 -0
- data/docs/TaskListEnvelope.md +12 -0
- data/docs/TaskParameters.md +9 -0
- data/docs/TaskRequest.md +13 -0
- data/docs/TaskStatus.md +13 -0
- data/docs/TaskStatusCounts.md +12 -0
- data/docs/TaskStatuses.md +19 -0
- data/docs/TaskStatusesEnvelope.md +11 -0
- data/docs/TaskStatusesHistoryEnvelope.md +8 -0
- data/docs/TaskUpdateRequest.md +8 -0
- data/docs/TaskUpdateResponse.md +8 -0
- data/docs/TasksStatusCounts.md +11 -0
- data/lib/artikcloud/api/device_types_api.rb +66 -0
- data/lib/artikcloud/api/devices_management_api.rb +971 -0
- data/lib/artikcloud/models/device_task.rb +250 -0
- data/lib/artikcloud/models/device_task_update_request.rb +200 -0
- data/lib/artikcloud/models/device_task_update_response.rb +200 -0
- data/lib/artikcloud/models/device_type_info.rb +260 -0
- data/lib/artikcloud/models/device_type_info_envelope.rb +199 -0
- data/lib/artikcloud/models/device_types_info.rb +260 -0
- data/lib/artikcloud/models/device_types_info_envelope.rb +199 -0
- data/lib/artikcloud/models/event_feed_data.rb +222 -0
- data/lib/artikcloud/models/metadata_envelope.rb +202 -0
- data/lib/artikcloud/models/metadata_properties_envelope.rb +201 -0
- data/lib/artikcloud/models/metadata_query_envelope.rb +232 -0
- data/lib/artikcloud/models/metadata_request.rb +190 -0
- data/lib/artikcloud/models/task.rb +302 -0
- data/lib/artikcloud/models/task_by_did.rb +314 -0
- data/lib/artikcloud/models/task_by_did_list.rb +202 -0
- data/lib/artikcloud/models/task_by_did_list_envelope.rb +230 -0
- data/lib/artikcloud/models/task_envelope.rb +200 -0
- data/lib/artikcloud/models/task_history.rb +250 -0
- data/lib/artikcloud/models/task_history_list.rb +202 -0
- data/lib/artikcloud/models/task_list.rb +202 -0
- data/lib/artikcloud/models/task_list_envelope.rb +240 -0
- data/lib/artikcloud/models/task_parameters.rb +210 -0
- data/lib/artikcloud/models/task_request.rb +252 -0
- data/lib/artikcloud/models/task_status.rb +250 -0
- data/lib/artikcloud/models/task_status_counts.rb +240 -0
- data/lib/artikcloud/models/task_statuses.rb +314 -0
- data/lib/artikcloud/models/task_statuses_envelope.rb +230 -0
- data/lib/artikcloud/models/task_statuses_history_envelope.rb +200 -0
- data/lib/artikcloud/models/task_update_request.rb +200 -0
- data/lib/artikcloud/models/task_update_response.rb +200 -0
- data/lib/artikcloud/models/tasks_status_counts.rb +230 -0
- data/lib/artikcloud/version.rb +1 -1
- data/lib/artikcloud.rb +31 -0
- data/pom.xml +1 -1
- data/spec/api/devices_api_spec.rb +7 -10
- data/spec/api/devices_management_api_spec.rb +251 -0
- data/spec/api/messages_api_spec.rb +67 -25
- data/spec/api/tokens_api_spec.rb +10 -33
- data/spec/api/users_api_spec.rb +65 -14
- data/spec/api_client_spec.rb +237 -0
- data/spec/configuration_spec.rb +53 -0
- data/spec/factories/devices.rb +32 -0
- data/spec/factories/users.rb +31 -0
- data/spec/fixtures/cassettes/DevicesApi/get_device_presence_test/should_work.yml +50 -0
- data/spec/fixtures/cassettes/MessagesApi/get_message_snapshots/should_work.yml +54 -0
- data/spec/fixtures/cassettes/MessagesApi/send_actions/should_work.yml +93 -0
- data/spec/fixtures/cassettes/MessagesApi/send_message_action_test/should_work.yml +99 -0
- data/spec/fixtures/cassettes/TokensApi/refresh_token_test/should_work.yml +43 -0
- data/spec/fixtures/cassettes/TokensApi/token_info_test/should_work.yml +38 -0
- data/spec/fixtures/cassettes/UsersApi/get_self_test/should_work.yml +53 -0
- data/spec/fixtures/cassettes/UsersApi/get_user_device_types_test/should_work.yml +55 -0
- data/spec/fixtures/cassettes/UsersApi/get_user_devices_test/should_work.yml +55 -0
- data/spec/fixtures/cassettes/UsersApi/get_user_properties_update_user_properties_and_delete_user_properties_test/should_work.yml +52 -0
- data/spec/fixtures/cassettes/UsersApi/get_user_rules_test/should_work.yml +58 -0
- data/spec/spec_helper.rb +20 -5
- metadata +142 -46
@@ -18,22 +18,13 @@ require 'json'
|
|
18
18
|
# Unit tests for ArtikCloud::MessagesApi
|
19
19
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
20
20
|
# Please update as you see appropriate
|
21
|
-
describe 'MessagesApi' do
|
22
|
-
|
23
|
-
|
24
|
-
configuration = ArtikCloud::Configuration.new
|
25
|
-
configuration.access_token = 'dc43d12e2b59495daf94631e6ddfe3e8'
|
26
|
-
api_client = ArtikCloud::ApiClient.new(configuration)
|
27
|
-
@instance = ArtikCloud::MessagesApi.new(api_client)
|
28
|
-
end
|
29
|
-
|
30
|
-
after do
|
31
|
-
# run after each test
|
32
|
-
end
|
21
|
+
describe 'MessagesApi', :vcr do
|
22
|
+
let(:instance) { ArtikCloud::MessagesApi.new(API_CLIENT) }
|
23
|
+
let(:device) { FactoryGirl.create(:device1) }
|
33
24
|
|
34
25
|
describe 'test an instance of MessagesApi' do
|
35
26
|
it 'should create an instact of MessagesApi' do
|
36
|
-
|
27
|
+
expect(instance).to be_a(ArtikCloud::MessagesApi)
|
37
28
|
end
|
38
29
|
end
|
39
30
|
|
@@ -47,14 +38,14 @@ describe 'MessagesApi' do
|
|
47
38
|
it "should work" do
|
48
39
|
message = ArtikCloud::Message.new
|
49
40
|
message.type = "message"
|
50
|
-
message.sdid =
|
41
|
+
message.sdid = device.id
|
51
42
|
message.ts = Time.now.to_f*1000
|
52
|
-
message.data =
|
53
|
-
|
54
|
-
|
43
|
+
message.data = {
|
44
|
+
:'steps' => 500
|
45
|
+
}
|
55
46
|
|
56
|
-
result =
|
57
|
-
result.
|
47
|
+
result = instance.send_message(message)
|
48
|
+
expect(result).to be_a(ArtikCloud::MessageIDEnvelope)
|
58
49
|
message_id = result.data.mid
|
59
50
|
|
60
51
|
sleep(2)
|
@@ -63,17 +54,68 @@ describe 'MessagesApi' do
|
|
63
54
|
:mid => message_id
|
64
55
|
}
|
65
56
|
|
66
|
-
normalized_messages =
|
67
|
-
normalized_messages.
|
68
|
-
normalized_messages.size.
|
57
|
+
normalized_messages = instance.get_normalized_messages(opts)
|
58
|
+
expect(normalized_messages).to be_a(ArtikCloud::NormalizedMessagesEnvelope)
|
59
|
+
expect(normalized_messages.size).to eq 1
|
69
60
|
|
70
61
|
normalized = normalized_messages.data[0]
|
71
|
-
normalized.mid.
|
62
|
+
expect(normalized.mid).to eq message_id
|
72
63
|
|
73
64
|
volume = normalized.data["steps"]
|
74
|
-
volume.
|
75
|
-
volume.
|
65
|
+
expect(volume).to_not be_nil
|
66
|
+
expect(volume).to eq 500
|
76
67
|
end
|
77
68
|
end
|
78
69
|
|
70
|
+
describe 'get_message_snapshots' do
|
71
|
+
it 'should work' do
|
72
|
+
result = instance.get_message_snapshots(device.id)
|
73
|
+
expect(result.sdids).to eq device.id
|
74
|
+
expect(result.data.first.sdid).to eq device.id
|
75
|
+
expect(result.data.first.data['steps'][:value]).to eq 500
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe 'send_actions' do
|
80
|
+
let(:device) { FactoryGirl.create(:device_tv) }
|
81
|
+
|
82
|
+
it 'should work' do
|
83
|
+
action = ArtikCloud::Action.new
|
84
|
+
action.name = 'setVolume'
|
85
|
+
action.parameters = {'volume' => 5}
|
86
|
+
|
87
|
+
action_array = ArtikCloud::ActionArray.new
|
88
|
+
action_array.actions = [action]
|
89
|
+
|
90
|
+
actions = ArtikCloud::Actions.new
|
91
|
+
actions.ddid = device.id
|
92
|
+
actions.ts = Time.now.to_f*1000
|
93
|
+
actions.data = action_array
|
94
|
+
|
95
|
+
mid = instance.send_actions(actions).data.mid
|
96
|
+
|
97
|
+
sleep(2)
|
98
|
+
|
99
|
+
result = instance.get_normalized_actions(
|
100
|
+
uid: nil,
|
101
|
+
ddid: nil,
|
102
|
+
mid: mid,
|
103
|
+
offset: nil,
|
104
|
+
count: nil,
|
105
|
+
startDate: nil,
|
106
|
+
endDate: nil,
|
107
|
+
order: nil
|
108
|
+
)
|
109
|
+
expect(result.size).to eq 1
|
110
|
+
|
111
|
+
normalized = result.data[0]
|
112
|
+
action_rx = normalized.data.actions[0]
|
113
|
+
|
114
|
+
expect(action_rx.name).to eq 'setVolume'
|
115
|
+
|
116
|
+
volume = action_rx.parameters['volume']
|
117
|
+
expect(volume).to_not be_nil
|
118
|
+
expect(volume).to eq 5
|
119
|
+
end
|
120
|
+
end
|
79
121
|
end
|
data/spec/api/tokens_api_spec.rb
CHANGED
@@ -18,53 +18,30 @@ require 'json'
|
|
18
18
|
# Unit tests for ArtikCloud::TokensApi
|
19
19
|
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
20
20
|
# Please update as you see appropriate
|
21
|
-
describe 'TokensApi' do
|
22
|
-
|
23
|
-
# run before each test
|
24
|
-
@token = 'fa460261b858484583097ecb331faaa8'
|
25
|
-
configuration = ArtikCloud::Configuration.new
|
26
|
-
configuration.access_token = @token
|
27
|
-
#configuration.base_url = 'https://accounts.artik.cloud'
|
28
|
-
configuration.debugging = false
|
29
|
-
api_client = ArtikCloud::ApiClient.new(configuration)
|
30
|
-
@instance = ArtikCloud::TokensApi.new(api_client)
|
31
|
-
end
|
32
|
-
|
33
|
-
after do
|
34
|
-
# run after each test
|
35
|
-
end
|
21
|
+
describe 'TokensApi', :vcr do
|
22
|
+
let(:instance) { ArtikCloud::TokensApi.new(API_CLIENT) }
|
36
23
|
|
37
24
|
describe 'test an instance of TokensApi' do
|
38
25
|
it 'should create an instact of TokensApi' do
|
39
|
-
|
26
|
+
expect(instance).to be_a(ArtikCloud::TokensApi)
|
40
27
|
end
|
41
28
|
end
|
42
29
|
|
43
|
-
# unit tests for tokenInfo
|
44
|
-
# Token Info
|
45
|
-
# @return [TokenInfoSuccessResponse]
|
46
30
|
describe 'token_info test' do
|
47
31
|
it "should work" do
|
48
|
-
response =
|
49
|
-
response.
|
50
|
-
|
32
|
+
response = instance.token_info
|
33
|
+
expect(response).to be_a(ArtikCloud::TokenInfoSuccessResponse)
|
34
|
+
expect(response.data.expires_in).to_not be_nil
|
51
35
|
end
|
52
36
|
end
|
53
37
|
|
54
|
-
# unit tests for refresh_token
|
55
|
-
# Refresh Token
|
56
|
-
# Refresh Token
|
57
|
-
# @param grant_type Grant Type.
|
58
|
-
# @param refresh_token Refresh Token.
|
59
|
-
# @param [Hash] opts the optional parameters
|
60
|
-
# @return [RefreshTokenResponse]
|
61
38
|
describe 'refresh_token test' do
|
62
39
|
it "should work" do
|
63
|
-
|
40
|
+
pending 'refresh_token is invalid, a good one is needed'
|
41
|
+
refresh_token = "bb90333aee114b3e97284814d978080d"
|
64
42
|
|
65
|
-
|
66
|
-
|
43
|
+
response = instance.refresh_token("refresh_token", refresh_token)
|
44
|
+
response.should be_a(ArtikCloud::RefreshTokenResponse)
|
67
45
|
end
|
68
46
|
end
|
69
|
-
|
70
47
|
end
|
data/spec/api/users_api_spec.rb
CHANGED
@@ -16,19 +16,13 @@ require 'spec_helper'
|
|
16
16
|
require 'json'
|
17
17
|
|
18
18
|
# Unit tests for ArtikCloud::UsersApi
|
19
|
-
describe 'UsersApi' do
|
20
|
-
|
21
|
-
|
22
|
-
@instance = ArtikCloud::UsersApi.new(API_CLIENT)
|
23
|
-
end
|
24
|
-
|
25
|
-
after do
|
26
|
-
# run after each test
|
27
|
-
end
|
19
|
+
describe 'UsersApi', :vcr do
|
20
|
+
let(:user){ FactoryGirl.create(:user) }
|
21
|
+
let(:instance) { ArtikCloud::UsersApi.new(API_CLIENT) }
|
28
22
|
|
29
23
|
describe 'test an instance of UsersApi' do
|
30
24
|
it 'should create an instact of UsersApi' do
|
31
|
-
|
25
|
+
expect(instance).to be_a(ArtikCloud::UsersApi)
|
32
26
|
end
|
33
27
|
end
|
34
28
|
|
@@ -39,12 +33,69 @@ describe 'UsersApi' do
|
|
39
33
|
# @return [UserEnvelope]
|
40
34
|
describe 'get_self test' do
|
41
35
|
it "should work" do
|
42
|
-
result =
|
36
|
+
result = instance.get_self
|
37
|
+
|
38
|
+
expect(result).to be_a(ArtikCloud::UserEnvelope)
|
39
|
+
expect(result.data.email).to eq user.email
|
40
|
+
expect(result.data.id).to eq user.id
|
41
|
+
expect(result.data.name).to eq user.name
|
42
|
+
expect(result.data.full_name).to eq user.full_name
|
43
|
+
expect(result.data.created_on).to eq user.created_on
|
44
|
+
expect(result.data.modified_on).to_not be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'get_user_devices test' do
|
49
|
+
it "should work" do
|
50
|
+
result = instance.get_user_devices(user.id)
|
51
|
+
expect(result).to be_a(ArtikCloud::DevicesEnvelope)
|
52
|
+
expect(result.data.devices).to_not be_nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'get_user_device_types test' do
|
57
|
+
it "should work" do
|
58
|
+
result = instance.get_user_device_types(user.id)
|
59
|
+
expect(result).to be_a(ArtikCloud::DeviceTypesEnvelope)
|
60
|
+
expect(result.data.device_types).to_not be_nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'get_user_properties, update_user_properties, and delete_user_properties test' do
|
65
|
+
it "should work", :new_episodes do
|
66
|
+
# get_user_properties
|
43
67
|
|
44
|
-
|
45
|
-
|
46
|
-
|
68
|
+
begin
|
69
|
+
result = instance.get_user_properties(user.id, aid: user.aid)
|
70
|
+
rescue ArtikCloud::ApiError => exception
|
71
|
+
if exception.code == 404
|
72
|
+
app_properties = ArtikCloud::AppProperties.new
|
73
|
+
app_properties.properties = 'abc=def'
|
74
|
+
result = instance.create_user_properties(user.id, app_properties, aid: user.aid)
|
75
|
+
else
|
76
|
+
raise "Non-404 Error returned by API"
|
77
|
+
end
|
78
|
+
expect(result).to_not be_nil
|
79
|
+
|
80
|
+
# update_user_properties
|
81
|
+
app_properties_update = ArtikCloud::AppProperties.new
|
82
|
+
app_properties_update.properties = 'mno=pqr'
|
83
|
+
result_update = instance.update_user_properties(user.id, app_properties_update, aid: user.aid)
|
84
|
+
expect(result_update).to_not be_nil
|
85
|
+
expect(result_update.data.properties).to eq 'mno=pqr'
|
86
|
+
|
87
|
+
# delete_user_properties
|
88
|
+
result_delete = instance.delete_user_properties(user.id, aid: user.aid)
|
89
|
+
expect(result_delete).to_not be_nil
|
90
|
+
expect(result_delete).to eq result_update
|
91
|
+
end
|
47
92
|
end
|
48
93
|
end
|
49
94
|
|
95
|
+
describe 'get_user_rules test' do
|
96
|
+
it "should work" do
|
97
|
+
result = instance.get_user_rules(user.id)
|
98
|
+
expect(result).to_not be_nil
|
99
|
+
end
|
100
|
+
end
|
50
101
|
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
=begin
|
2
|
+
#ARTIK Cloud API
|
3
|
+
|
4
|
+
#No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
you may not use this file except in compliance with the License.
|
12
|
+
You may obtain a copy of the License at
|
13
|
+
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
See the License for the specific language governing permissions and
|
20
|
+
limitations under the License.
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'spec_helper'
|
25
|
+
|
26
|
+
describe ArtikCloud::ApiClient do
|
27
|
+
context 'initialization' do
|
28
|
+
context 'URL stuff' do
|
29
|
+
context 'host' do
|
30
|
+
it 'removes http from host' do
|
31
|
+
ArtikCloud.configure { |c| c.host = 'http://example.com' }
|
32
|
+
expect(ArtikCloud::Configuration.default.host).to eq('example.com')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'removes https from host' do
|
36
|
+
ArtikCloud.configure { |c| c.host = 'https://wookiee.com' }
|
37
|
+
expect(ArtikCloud::ApiClient.default.config.host).to eq('wookiee.com')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'removes trailing path from host' do
|
41
|
+
ArtikCloud.configure { |c| c.host = 'hobo.com/v4' }
|
42
|
+
expect(ArtikCloud::Configuration.default.host).to eq('hobo.com')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'base_path' do
|
47
|
+
it "prepends a slash to base_path" do
|
48
|
+
ArtikCloud.configure { |c| c.base_path = 'v4/dog' }
|
49
|
+
expect(ArtikCloud::Configuration.default.base_path).to eq('/v4/dog')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "doesn't prepend a slash if one is already there" do
|
53
|
+
ArtikCloud.configure { |c| c.base_path = '/v4/dog' }
|
54
|
+
expect(ArtikCloud::Configuration.default.base_path).to eq('/v4/dog')
|
55
|
+
end
|
56
|
+
|
57
|
+
it "ends up as a blank string if nil" do
|
58
|
+
ArtikCloud.configure { |c| c.base_path = nil }
|
59
|
+
expect(ArtikCloud::Configuration.default.base_path).to eq('')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "params_encoding in #build_request" do
|
66
|
+
let(:config) { ArtikCloud::Configuration.new }
|
67
|
+
let(:api_client) { ArtikCloud::ApiClient.new(config) }
|
68
|
+
|
69
|
+
it "defaults to nil" do
|
70
|
+
expect(ArtikCloud::Configuration.default.params_encoding).to eq(nil)
|
71
|
+
expect(config.params_encoding).to eq(nil)
|
72
|
+
|
73
|
+
request = api_client.build_request(:get, '/test')
|
74
|
+
expect(request.options[:params_encoding]).to eq(nil)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "can be customized" do
|
78
|
+
config.params_encoding = :multi
|
79
|
+
request = api_client.build_request(:get, '/test')
|
80
|
+
expect(request.options[:params_encoding]).to eq(:multi)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "timeout in #build_request" do
|
85
|
+
let(:config) { ArtikCloud::Configuration.new }
|
86
|
+
let(:api_client) { ArtikCloud::ApiClient.new(config) }
|
87
|
+
|
88
|
+
it "defaults to 0" do
|
89
|
+
expect(ArtikCloud::Configuration.default.timeout).to eq(0)
|
90
|
+
expect(config.timeout).to eq(0)
|
91
|
+
|
92
|
+
request = api_client.build_request(:get, '/test')
|
93
|
+
expect(request.options[:timeout]).to eq(0)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "can be customized" do
|
97
|
+
config.timeout = 100
|
98
|
+
request = api_client.build_request(:get, '/test')
|
99
|
+
expect(request.options[:timeout]).to eq(100)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#deserialize" do
|
104
|
+
it "handles Array<Integer>" do
|
105
|
+
api_client = ArtikCloud::ApiClient.new
|
106
|
+
headers = {'Content-Type' => 'application/json'}
|
107
|
+
response = double('response', headers: headers, body: '[12, 34]')
|
108
|
+
data = api_client.deserialize(response, 'Array<Integer>')
|
109
|
+
expect(data).to be_instance_of(Array)
|
110
|
+
expect(data).to eq([12, 34])
|
111
|
+
end
|
112
|
+
|
113
|
+
it "handles Array<Array<Integer>>" do
|
114
|
+
api_client = ArtikCloud::ApiClient.new
|
115
|
+
headers = {'Content-Type' => 'application/json'}
|
116
|
+
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
117
|
+
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
118
|
+
expect(data).to be_instance_of(Array)
|
119
|
+
expect(data).to eq([[12, 34], [56]])
|
120
|
+
end
|
121
|
+
|
122
|
+
it "handles Hash<String, String>" do
|
123
|
+
api_client = ArtikCloud::ApiClient.new
|
124
|
+
headers = {'Content-Type' => 'application/json'}
|
125
|
+
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
126
|
+
data = api_client.deserialize(response, 'Hash<String, String>')
|
127
|
+
expect(data).to be_instance_of(Hash)
|
128
|
+
expect(data).to eq({:message => 'Hello'})
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#object_to_hash" do
|
133
|
+
it "ignores nils and includes empty arrays" do
|
134
|
+
# uncomment below to test object_to_hash for model
|
135
|
+
#api_client = ArtikCloud::ApiClient.new
|
136
|
+
#_model = ArtikCloud::ModelName.new
|
137
|
+
# update the model attribute below
|
138
|
+
#_model.id = 1
|
139
|
+
# update the expected value (hash) below
|
140
|
+
#expected = {id: 1, name: '', tags: []}
|
141
|
+
#expect(api_client.object_to_hash(_model)).to eq(expected)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "#build_collection_param" do
|
146
|
+
let(:param) { ['aa', 'bb', 'cc'] }
|
147
|
+
let(:api_client) { ArtikCloud::ApiClient.new }
|
148
|
+
|
149
|
+
it "works for csv" do
|
150
|
+
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
151
|
+
end
|
152
|
+
|
153
|
+
it "works for ssv" do
|
154
|
+
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
155
|
+
end
|
156
|
+
|
157
|
+
it "works for tsv" do
|
158
|
+
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
159
|
+
end
|
160
|
+
|
161
|
+
it "works for pipes" do
|
162
|
+
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
163
|
+
end
|
164
|
+
|
165
|
+
it "works for multi" do
|
166
|
+
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
167
|
+
end
|
168
|
+
|
169
|
+
it "fails for invalid collection format" do
|
170
|
+
expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "#json_mime?" do
|
175
|
+
let(:api_client) { ArtikCloud::ApiClient.new }
|
176
|
+
|
177
|
+
it "works" do
|
178
|
+
expect(api_client.json_mime?(nil)).to eq false
|
179
|
+
expect(api_client.json_mime?('')).to eq false
|
180
|
+
|
181
|
+
expect(api_client.json_mime?('application/json')).to eq true
|
182
|
+
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
|
183
|
+
expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
|
184
|
+
|
185
|
+
expect(api_client.json_mime?('application/xml')).to eq false
|
186
|
+
expect(api_client.json_mime?('text/plain')).to eq false
|
187
|
+
expect(api_client.json_mime?('application/jsonp')).to eq false
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "#select_header_accept" do
|
192
|
+
let(:api_client) { ArtikCloud::ApiClient.new }
|
193
|
+
|
194
|
+
it "works" do
|
195
|
+
expect(api_client.select_header_accept(nil)).to be_nil
|
196
|
+
expect(api_client.select_header_accept([])).to be_nil
|
197
|
+
|
198
|
+
expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
|
199
|
+
expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
200
|
+
expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
201
|
+
|
202
|
+
expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
|
203
|
+
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe "#select_header_content_type" do
|
208
|
+
let(:api_client) { ArtikCloud::ApiClient.new }
|
209
|
+
|
210
|
+
it "works" do
|
211
|
+
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
212
|
+
expect(api_client.select_header_content_type([])).to eq('application/json')
|
213
|
+
|
214
|
+
expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
|
215
|
+
expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
216
|
+
expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
217
|
+
expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
|
218
|
+
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "#sanitize_filename" do
|
223
|
+
let(:api_client) { ArtikCloud::ApiClient.new }
|
224
|
+
|
225
|
+
it "works" do
|
226
|
+
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
227
|
+
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
228
|
+
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
229
|
+
expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
|
230
|
+
expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
|
231
|
+
expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
|
232
|
+
expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
|
233
|
+
expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
|
234
|
+
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
=begin
|
2
|
+
#ARTIK Cloud API
|
3
|
+
|
4
|
+
#No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
you may not use this file except in compliance with the License.
|
12
|
+
You may obtain a copy of the License at
|
13
|
+
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
See the License for the specific language governing permissions and
|
20
|
+
limitations under the License.
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'spec_helper'
|
25
|
+
|
26
|
+
describe ArtikCloud::Configuration do
|
27
|
+
let(:config) { ArtikCloud::Configuration.default }
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
# uncomment below to setup host and base_path
|
31
|
+
#require 'URI'
|
32
|
+
#uri = URI.parse("https://api.artik.cloud/v1.1")
|
33
|
+
#ArtikCloud.configure do |c|
|
34
|
+
# c.host = uri.host
|
35
|
+
# c.base_path = uri.path
|
36
|
+
#end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#base_url' do
|
40
|
+
it 'should have the default value' do
|
41
|
+
# uncomment below to test default value of the base path
|
42
|
+
#expect(config.base_url).to eq("https://api.artik.cloud/v1.1")
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should remove trailing slashes' do
|
46
|
+
[nil, '', '/', '//'].each do |base_path|
|
47
|
+
config.base_path = base_path
|
48
|
+
# uncomment below to test trailing slashes
|
49
|
+
#expect(config.base_url).to eq("https://api.artik.cloud/v1.1")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
skip_create
|
5
|
+
factory :device1, class: OpenStruct do
|
6
|
+
id '19da42ee01414722a6ad1224097c38d4'
|
7
|
+
token 'dc43d12e2b59495daf94631e6ddfe3e8'
|
8
|
+
|
9
|
+
initialize_with { new(attributes) }
|
10
|
+
end
|
11
|
+
|
12
|
+
factory :device2, class: OpenStruct do
|
13
|
+
id '16f54be9b9ce4c69be14a6c8ff33ea8d'
|
14
|
+
token 'f9f75bd0b0fc46a9a604703909f4331d'
|
15
|
+
|
16
|
+
initialize_with { new(attributes) }
|
17
|
+
end
|
18
|
+
|
19
|
+
factory :device3, class: OpenStruct do
|
20
|
+
id '3dd34bce025a4409ac1ff80be81b8dbc'
|
21
|
+
token '49db2612c46342458b61af535921bdca'
|
22
|
+
|
23
|
+
initialize_with { new(attributes) }
|
24
|
+
end
|
25
|
+
|
26
|
+
factory :device_tv, class: OpenStruct do
|
27
|
+
id '5c97745b1e7a4beb96edd583ad595884'
|
28
|
+
token '56482b3f3ca948d3bc8769a003bfeb7f'
|
29
|
+
|
30
|
+
initialize_with { new(attributes) }
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
skip_create
|
5
|
+
factory :user, class: OpenStruct do
|
6
|
+
id "04ddbd35d57d4d7b8f07f219c44457b2"
|
7
|
+
aid "b6951bf387b84f63b38911ae35d65e28"
|
8
|
+
name "maneesh"
|
9
|
+
email "maneesh.sahu@ssi.samsung.com"
|
10
|
+
full_name "Maneesh Sahu"
|
11
|
+
sa_identity "kqil5l7kgb"
|
12
|
+
account_type "SAMSUNG"
|
13
|
+
created_on 1406839290000
|
14
|
+
modified_on 1413483926000
|
15
|
+
|
16
|
+
initialize_with { new(attributes) }
|
17
|
+
end
|
18
|
+
|
19
|
+
factory :artik_user, class: ArtikCloud::User do
|
20
|
+
id "04ddbd35d57d4d7b8f07f219c44457b2"
|
21
|
+
name "maneesh"
|
22
|
+
email "maneesh.sahu@ssi.samsung.com"
|
23
|
+
fullName "Maneesh Sahu"
|
24
|
+
saIdentity "kqil5l7kgb"
|
25
|
+
accountType "SAMSUNG"
|
26
|
+
createdOn 1406839290000
|
27
|
+
modifiedOn 1413483926000
|
28
|
+
|
29
|
+
initialize_with { new(attributes) }
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.artik.cloud/v1.1/devices/19da42ee01414722a6ad1224097c38d4/presence
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Swagger-Codegen/2.0.5/ruby
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Accept:
|
15
|
+
- application/json
|
16
|
+
Authorization:
|
17
|
+
- Bearer fa460261b858484583097ecb331faaa8
|
18
|
+
Expect:
|
19
|
+
- ''
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Content-Type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
X-Rate-Limit-Limit:
|
28
|
+
- 100/1000
|
29
|
+
X-Rate-Limit-Reset:
|
30
|
+
- 1472795198/1472860800
|
31
|
+
X-Rate-Limit-Remaining:
|
32
|
+
- 99/999
|
33
|
+
Access-Control-Allow-Origin:
|
34
|
+
- "*"
|
35
|
+
Access-Control-Allow-Headers:
|
36
|
+
- Origin, X-Requested-With, Content-Type, Accept, Referer, User-Agent, Authorization
|
37
|
+
Access-Control-Allow-Methods:
|
38
|
+
- POST, GET, PUT, DELETE, OPTIONS
|
39
|
+
Date:
|
40
|
+
- Fri, 02 Sep 2016 05:45:38 GMT
|
41
|
+
Content-Length:
|
42
|
+
- '97'
|
43
|
+
Connection:
|
44
|
+
- close
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"sdid":"19da42ee01414722a6ad1224097c38d4","data":{"lastSeenOn":1472795114293,"connected":false}}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 02 Sep 2016 05:45:38 GMT
|
50
|
+
recorded_with: VCR 3.0.3
|