atlas-utils 0.0.1 → 0.0.5
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/lib/atlas_utils.rb +67 -73
- data/lib/atlas_utils/rest_helper.rb +0 -60
- data/lib/atlas_utils/test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e96aa8d3dff545f16b4940a087e7c264f682be82b4ac9a86a106fa7fff779e1e
|
4
|
+
data.tar.gz: 32115b02c0c2e4b9ac6e90170c4c8345874d64b8b53c1abf5cf74d91d93a7fe6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6087f43fb2b3f7c1367234849e2559396bcc1e072199183787faeb06cc81c21b03920cdd3cf63cacc74fd8ace27d80052ca99c9c9ff460eef400d12a6c692693
|
7
|
+
data.tar.gz: d29a04182a02476c5e4aa66f2c964de8054d893673ace5ddfb11690b5196df2aa46d6d7b805a8859a4049d43ecf2ac76cbcf6b604ba1292021436819055d55fd
|
data/lib/atlas_utils.rb
CHANGED
@@ -8,8 +8,8 @@ module AtlasUtils
|
|
8
8
|
@platform = config_params[:platform]
|
9
9
|
@language = config_params[:language]
|
10
10
|
@territory = config_params[:territory]
|
11
|
-
@
|
12
|
-
@
|
11
|
+
@base_pcms_url = configurator['hosts'][@env]
|
12
|
+
@root_menu_url = @base_pcms_url + configurator['seamlessUrl']
|
13
13
|
|
14
14
|
puts "Env: #{@env} Device: #{@device} Platform: #{@platform } Lang: #{@language} Territory: #{@territory}"
|
15
15
|
end
|
@@ -27,112 +27,106 @@ module AtlasUtils
|
|
27
27
|
RestHelper.get_from_api(@root_menu_url)
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def root_menu_json
|
31
31
|
api_response(@root_menu_url)
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def sub_menu_titles
|
39
|
-
sub_menu_json.map { |menu| menu['attributes']['title'] }
|
34
|
+
def menu_json
|
35
|
+
root_menu_json['relationships']['items']['data']
|
40
36
|
end
|
41
37
|
|
42
|
-
def
|
43
|
-
|
38
|
+
def menu_titles
|
39
|
+
menu_json.map { |menu| menu['attributes']['title'] }
|
44
40
|
end
|
45
41
|
|
46
|
-
def
|
47
|
-
|
48
|
-
sub_menu_json.each do |collection|
|
49
|
-
sub_menu_item_json = collection['relationships']['items']['data'] if collection['attributes']['alias'] == menu
|
50
|
-
end
|
51
|
-
sub_menu_item_json
|
42
|
+
def sub_menu_titles(menu)
|
43
|
+
menu_item_json(menu)['relationships']['items']['data'].map { |menu| menu['attributes']['title'] }
|
52
44
|
end
|
53
45
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
46
|
+
def menu_item_json(menu)
|
47
|
+
menu_item_json = nil
|
48
|
+
menu_json.each do |collection|
|
49
|
+
if collection['attributes']['title'].casecmp(menu)==0
|
50
|
+
if collection['relationships'] && collection['relationships']['items']
|
51
|
+
menu_item_json = collection
|
52
|
+
end
|
60
53
|
end
|
61
|
-
end
|
62
|
-
catalogue_group_json
|
63
|
-
end
|
64
54
|
|
65
|
-
def sub_menu_url(menu, menu_item)
|
66
|
-
return_url = nil
|
67
|
-
catalogue_group_json = catalogue_group_json(menu, menu_item)
|
68
|
-
catalogue_group_json.each do |catalogue_group_collection|
|
69
|
-
catalogue_collection_json = api_response(@root_pcms_url
|
70
|
-
.+ catalogue_group_collection['links']['self']
|
71
|
-
.+ '?represent=(items)')
|
72
|
-
return_url = catalogue_collection_json['relationships']['items']['data'][0]['links']['self']
|
73
|
-
return_url += '?represent=(items[take=50,skip=0])'
|
74
55
|
end
|
75
|
-
|
56
|
+
menu_item_json
|
76
57
|
end
|
77
58
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
59
|
+
def catalogue_collections(link)
|
60
|
+
sub_catalogue_titles_collection = []
|
61
|
+
sub_collection_json = api_response(@base_pcms_url
|
62
|
+
.+ link + '?represent=(items)')
|
63
|
+
if sub_collection_json['type']=='CATALOGUE/GROUP'
|
64
|
+
# puts "Collection:==> #{sub_collection_json['attributes']['title']} is a GROUP"
|
65
|
+
sub_collection_json['relationships']['items']['data'].each do |sub_group|
|
66
|
+
sub_catalogue_titles_collection.concat(catalogue_collections(sub_group['links']['self']))
|
67
|
+
end
|
68
|
+
else
|
69
|
+
if sub_collection_json['relationships'] && sub_collection_json['relationships']['items']
|
70
|
+
sub_catalogue_titles_collection.concat(sub_collection_json['relationships']['items']['data'])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
return sub_catalogue_titles_collection
|
84
74
|
end
|
85
75
|
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
movie_data
|
76
|
+
def catalogue_group_json(menu)
|
77
|
+
menu_item_json = menu_item_json(menu)
|
78
|
+
puts "Getting all asset details for #{menu} menu...."
|
79
|
+
catalogue_collections(menu_item_json['links']['self'])
|
91
80
|
end
|
92
81
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
82
|
+
def catalogue_collection(menu)
|
83
|
+
menu_titles.each do |menu_title|
|
84
|
+
if menu_title.casecmp(menu) == 0
|
85
|
+
unless instance_variable_get("@catalogue_#{menu}_collection")
|
86
|
+
instance_variable_set("@catalogue_#{menu}_collection",catalogue_group_json(menu))
|
87
|
+
end
|
88
|
+
return instance_variable_get("@catalogue_#{menu}_collection")
|
89
|
+
end
|
90
|
+
end
|
98
91
|
end
|
99
92
|
|
100
|
-
def
|
101
|
-
|
102
|
-
sub_menu_json.each do |collection|
|
103
|
-
menu_title = collection['attributes']['title'] if collection['attributes']['alias'] == menu_alias
|
104
|
-
end
|
105
|
-
menu_title
|
93
|
+
def api_response(url)
|
94
|
+
RestHelper.get_from_api(url, json_headers)
|
106
95
|
end
|
107
96
|
|
108
|
-
def
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
97
|
+
def get_asset_details_using_title(menu, asset_title)
|
98
|
+
assets_in_catalogue = catalogue_collection(menu)
|
99
|
+
# puts assets_in_catalogue
|
100
|
+
asset = assets_in_catalogue.find {|e| e['attributes']['title'].casecmp(asset_title)==0}
|
101
|
+
if asset
|
102
|
+
return get_asset_details_from_nodeid(asset['id'])
|
103
|
+
else
|
104
|
+
return "No asset matched title #{asset_title}"
|
115
105
|
end
|
116
|
-
menu_item_title
|
117
106
|
end
|
118
107
|
|
119
|
-
def
|
120
|
-
node_url = @configurator['
|
121
|
-
asset_details_from_api = api_response(node_url+node_id)
|
108
|
+
def get_asset_details_from_nodeid(node_id)
|
109
|
+
node_url = @configurator['node_url']
|
110
|
+
asset_details_from_api = api_response(@base_pcms_url+ node_url + node_id)
|
122
111
|
asset_details_from_api
|
123
112
|
end
|
124
113
|
end
|
125
114
|
|
126
|
-
def self.test_settings(config)
|
127
|
-
|
115
|
+
def self.test_settings(config_type, config)
|
116
|
+
if config_type == "YML"
|
117
|
+
puts config
|
118
|
+
return (@test_settings ||= YAML.load_file(AtlasUtils.get_file_path(config)))
|
119
|
+
else
|
120
|
+
return (@test_settings ||= JSON.parse(File.read(AtlasUtils.get_file_path(config))))
|
121
|
+
end
|
128
122
|
end
|
129
123
|
|
130
124
|
def self.get_file_path(filename)
|
131
125
|
File.join(Dir.pwd, filename)
|
132
126
|
end
|
133
127
|
|
134
|
-
def self.menu_api_helper(config, config_params)
|
135
|
-
configurator = AtlasUtils.test_settings(config)
|
128
|
+
def self.menu_api_helper(config_type, config, config_params)
|
129
|
+
configurator = AtlasUtils.test_settings(config_type, config)
|
136
130
|
@menu_api_helper ||= AtlasUtils::Menu.new(configurator, config_params)
|
137
131
|
end
|
138
132
|
end
|
@@ -10,7 +10,6 @@ class RestHelper
|
|
10
10
|
begin
|
11
11
|
tries ||= 3
|
12
12
|
api_response = RestClient.get(url, headers) { |response, _request| response }
|
13
|
-
# expect(api_response.code).to eq(200)
|
14
13
|
if api_response.code != 200
|
15
14
|
puts "ERROR in get_from_api: response code #{api_response.code}"
|
16
15
|
end
|
@@ -29,63 +28,4 @@ class RestHelper
|
|
29
28
|
end
|
30
29
|
respo
|
31
30
|
end
|
32
|
-
|
33
|
-
def self.get_from_api_search(url)
|
34
|
-
api_response = RestClient.get(url, json_headers_search) { |response, _request| response }
|
35
|
-
# expect(api_response.code).to eq(200)
|
36
|
-
if api_response.code != 200
|
37
|
-
puts "ERROR in get_from_api_search: response code #{api_response.code}"
|
38
|
-
end
|
39
|
-
JSON.parse(api_response)
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.json_headers_search
|
43
|
-
headers = { 'x-skyott-proposition' => 'NOWTV',
|
44
|
-
'x-skyott-language' => 'en',
|
45
|
-
'x-skyott-territory' => 'GB' }
|
46
|
-
|
47
|
-
# headers['sky-resiliency'] = ENV['RESILIENCY_HEADER'] if ENV['RESILIENCY_HEADER']
|
48
|
-
headers
|
49
|
-
end
|
50
|
-
|
51
|
-
# captcha
|
52
|
-
def self.clear_captcha_if_presented(sign_in_url, username, password)
|
53
|
-
sign_in_payload = 'userIdentifier='"#{username}"'&password='"#{password}"
|
54
|
-
api_response = RestClient.post(sign_in_url, sign_in_payload, rango_headers) { |response, _request| response }
|
55
|
-
puts "API Response: \n #{api_response}"
|
56
|
-
clear_captcha(JSON.parse(api_response)) unless api_response.code.eql?(201)
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.clear_captcha(api_response)
|
60
|
-
captcha_url = 'https://uiapi.id.stage.nowtv.com/signin/securitycheck/service/international'
|
61
|
-
puts "Captcha URL: #{captcha_url}"
|
62
|
-
captcha_session_id = api_response['actions'][0]['fields'][2]['value']
|
63
|
-
captcha_id, captcha_value = get_captcha(captcha_url)
|
64
|
-
puts "captchaid, value : #{captcha_id}, #{captcha_value}"
|
65
|
-
send_captcha(captcha_url, captcha_id, captcha_value, captcha_session_id)
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.send_captcha(captcha_url, captcha_id, captcha_value, captcha_session_id)
|
69
|
-
payload = 'captcha='"#{captcha_value}"'&captchaId='"#{captcha_id}"'&captchaSessionId='"#{captcha_session_id}"
|
70
|
-
puts "send captcha payload #{payload}"
|
71
|
-
api_response = RestClient.post(captcha_url, payload, rango_headers) { |response, _request| response }
|
72
|
-
puts "response code : #{api_response.code}"
|
73
|
-
puts "response : #{api_response}"
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.get_captcha(captcha_url)
|
77
|
-
api_response = RestClient.post(captcha_url, '', rango_headers) { |response, _request| response }
|
78
|
-
captcha_id = JSON.parse(api_response)['properties']['captchaId']
|
79
|
-
captcha_value = api_response.cookies['captchaValue']
|
80
|
-
[captcha_id, captcha_value]
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.rango_headers
|
84
|
-
{
|
85
|
-
'content-type' => 'application/x-www-form-urlencoded',
|
86
|
-
'x-skyott-provider' => 'NOWTV',
|
87
|
-
'x-skyott-territory' => 'GB'
|
88
|
-
}
|
89
|
-
end
|
90
|
-
# end of captcha
|
91
31
|
end
|
data/lib/atlas_utils/test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atlas-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sripriya Raghunatha
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: sripriya.raghunatha@sky.uk
|