atlas-utils 0.0.0 → 0.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bae9a183af4b390a18da60041426509857f69542f049544386c5b43aa2688569
4
- data.tar.gz: 94c0efd9dc8c238d89fa52e8a82c17017072306f26d9ff9513378237dc1fd709
3
+ metadata.gz: 714728b6ef1099397525bb40d6172995444cbc1a3e49de7c84ba191ed8940c87
4
+ data.tar.gz: 5eefc6e33e5aabeb394f73d49d8791e9939d51229525d2fd4de42c9e7ae61667
5
5
  SHA512:
6
- metadata.gz: f274726b8d638091376725d976434b467744cf964eba9e4ea9706fb477c3dffbe38245d0181d7d777813d104b0bbaa06d863dfe11b4656283ecf767e705a11a0
7
- data.tar.gz: b61556b17264354e265c8991418eb74fbe46cb528bf54b9ece003aeff38ca666300abdd779afe0143638708d25ee54c6dffa07213e2baf021c73d1d175d3f6fb
6
+ metadata.gz: 2e4fa91681f550840bbe37c782d7ed2de5b08b1373614dc5005c332828eca7beafdb7ed951aef450183912884643bbac55dd456e8f251908ff700bad6b450094
7
+ data.tar.gz: 85b6d4815ed2f52591ec72cb4c6df4004f7b32df8e96699fe7d5d2fc13b7a1f4a52a53d073194118a88c4c1ea7f135f02ecbe356f5d2133477233f82f2feeb41
@@ -1,31 +1,24 @@
1
1
  require 'json'
2
2
  require 'rest-client'
3
+ require 'rspec'
4
+ require 'rspec/expectations'
3
5
 
4
6
  class RestHelper
5
- def self.get_from_api(url, additional_headers = {})
7
+ def self.get_from_api(url, json_headers, additional_headers = {})
6
8
  headers = json_headers
7
9
  headers.merge!(additional_headers)
8
-
9
- puts "URL: #{url}"
10
- puts "HEADERS: #{headers}"
11
- puts "!!!!!!!!!!!!!!!!!!!!!!"
12
- # $LOG.debug("URL: #{url}")
13
- # $LOG.debug("HEADERS: #{headers}")
14
-
15
10
  begin
16
11
  tries ||= 3
17
12
  api_response = RestClient.get(url, headers) { |response, _request| response }
18
- puts "RESPONSE CODE: #{api_response.code}"
19
- api_response.code.should be == 200
20
- respo = JSON.parse(api_response)
21
-
22
- pcms_pattern = %r{\/adapter-atlas\/v3\/query\/node\/(.*)}
23
- if url.match(pcms_pattern)
24
- puts "NODE ID FROM RESPONSE: #{respo['id']}"
25
- expect(respo['id']).to eq(url.match(pcms_pattern)[1].split('?').first)
13
+ # expect(api_response.code).to eq(200)
14
+ if api_response.code != 200
15
+ puts "ERROR in get_from_api: response code #{api_response.code}"
26
16
  end
27
- rescue
28
- puts'RESCUE in get_from_api'
17
+ respo = JSON.parse(api_response)
18
+ rescue => e
19
+ puts 'RESCUE in get_from_api@'
20
+ puts e.message
21
+ puts "======="
29
22
  if (tries -= 1) > 0
30
23
  puts'RETRY REQUEST'
31
24
  retry
@@ -37,21 +30,12 @@ class RestHelper
37
30
  respo
38
31
  end
39
32
 
40
- def self.json_headers
41
- headers = { 'Content-Type' => 'application/json',
42
- 'x-skyott-proposition' => 'NOWTV',
43
- 'x-skyott-language' => 'en',
44
- 'x-skyott-territory' => 'GB',
45
- 'x-skyott-platform' => 'APPLETV',
46
- 'x-skyott-device' => 'IPSETTOPBOX' }
47
-
48
- # headers['sky-resiliency'] = ENV['RESILIENCY_HEADER'] if ENV['RESILIENCY_HEADER']
49
- headers
50
- end
51
-
52
33
  def self.get_from_api_search(url)
53
34
  api_response = RestClient.get(url, json_headers_search) { |response, _request| response }
54
- api_response.code.should be == 200
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
55
39
  JSON.parse(api_response)
56
40
  end
57
41
 
@@ -1,7 +1,7 @@
1
1
  module AtlasUtils
2
2
  class WhoIs
3
3
  def self.awesome?
4
- puts "PRIYA IS AWESOME!!"
4
+ puts "PRIYA: WORLD IS ALWAYS AWESOME!!"
5
5
  end
6
6
  end
7
7
  end
data/lib/atlas_utils.rb CHANGED
@@ -1,11 +1,26 @@
1
1
  module AtlasUtils
2
2
  class Menu
3
- def initialize(base_menu_url, base_pcms_url)
4
- puts base_menu_url
5
- puts base_pcms_url
6
- puts "******"
7
- @root_menu_url = base_menu_url
8
- @root_pcms_url = base_pcms_url
3
+ def initialize(configurator, config_params)
4
+
5
+ @configurator = configurator
6
+ @env = config_params[:env]
7
+ @device = config_params[:device]
8
+ @platform = config_params[:platform]
9
+ @language = config_params[:language]
10
+ @territory = config_params[:territory]
11
+ @root_menu_url = configurator['environments'][@env][@territory]['base_seamless_url']
12
+ @root_pcms_url = configurator['environments'][@env][@territory]['base_pcms_url']
13
+
14
+ puts "Env: #{@env} Device: #{@device} Platform: #{@platform } Lang: #{@language} Territory: #{@territory}"
15
+ end
16
+
17
+ def json_headers
18
+ headers = { 'X-SkyOTT-Proposition' => 'NOWTV',
19
+ 'X-SkyOTT-Language' => @language,
20
+ 'X-SkyOTT-Territory' => @territory,
21
+ 'X-SkyOTT-Platform' => @platform,
22
+ 'X-SkyOTT-Device' => @device }
23
+ headers
9
24
  end
10
25
 
11
26
  def root_menu_collection
@@ -17,7 +32,7 @@ module AtlasUtils
17
32
  end
18
33
 
19
34
  def sub_menu_json
20
- menu_json['relationships']['items']['data'][1]['relationships']['items']['data']
35
+ menu_json['relationships']['items']['data']
21
36
  end
22
37
 
23
38
  def sub_menu_titles
@@ -25,7 +40,7 @@ module AtlasUtils
25
40
  end
26
41
 
27
42
  def api_response(url)
28
- RestHelper.get_from_api(url)
43
+ RestHelper.get_from_api(url, json_headers)
29
44
  end
30
45
 
31
46
  def sub_menu_item_json(menu)
@@ -100,16 +115,28 @@ module AtlasUtils
100
115
  end
101
116
  menu_item_title
102
117
  end
118
+
119
+ def get_asset_details(node_id)
120
+ node_url = @configurator['environments'][@env][@territory]['node_url']
121
+ asset_details_from_api = api_response(node_url+node_id)
122
+ asset_details_from_api
123
+ end
103
124
  end
104
125
 
126
+ def self.test_settings(config)
127
+ @test_settings ||= YAML.load_file(AtlasUtils.get_file_path(config))
128
+ end
129
+
130
+ def self.get_file_path(filename)
131
+ File.join(Dir.pwd, filename)
132
+ end
105
133
 
106
- def self.menu_api_helper
107
- base_menu_url = "https://ie.api.atom.nowtv.com/adapter-atlas/v3/query/node/group_id/Home?represent=(items[where=(type=CATALOGUE/COLLECTION),take=1](items[where=(type=ASSET/PROGRAMME%7CCATALOGUE/SERIES%7CASSET/LINEAR%7CASSET/EPISODE%7CCATALOGUE/SEASON)]),items[where=(type=CATALOGUE/LINK)],items[where=(type=CATALOGUE/GROUP)](items[where=(type=CATALOGUE/COLLECTION),take=1](items[take=10]))))"
108
- base_pcms_url = "http://ie.api.atom.nowtv.com"
109
- puts "In MAH"
110
- @menu_api_helper ||= AtlasUtils::Menu.new(base_menu_url, base_pcms_url)
134
+ def self.menu_api_helper(config, config_params)
135
+ configurator = AtlasUtils.test_settings(config)
136
+ @menu_api_helper ||= AtlasUtils::Menu.new(configurator, config_params)
111
137
  end
112
138
  end
113
139
 
114
140
  require 'atlas_utils/rest_helper.rb'
115
141
  require 'atlas_utils/test'
142
+ require 'yaml'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlas-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sripriya Raghunatha