AvrijAnalyticsUtility 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/lib/AvrijAnalyticsUtility/APIConnection.rb +77 -14
- data/lib/AvrijAnalyticsUtility/version.rb +1 -1
- data/lib/AvrijAnalyticsUtility.rb +53 -43
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6360dbe36f72a703e62c4e2dd49609ce7f5fd9a
|
4
|
+
data.tar.gz: 467a95abff98dba3a60e1db4e202097bf6c20aaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8db5386a39a4d64e0fd4f29a9f345e2f96c417e1897720b7fa5c1203d585a81e74f16aff5c222e56a2bc2fcfa921e906a864d423c45354fafe1cfc0cb88ced0c
|
7
|
+
data.tar.gz: d45a02fae80ab38a4394e2f3589da13e65d4ca1f8d21c73414cb37ab690bb9b61a9b061e8eec4185d79a9968f2386e3b37ae6733a21a463af7338205db54341b
|
data/Rakefile
CHANGED
@@ -8,24 +8,93 @@ class AvrijAnalyticsUtility::APIConnection
|
|
8
8
|
@AUTH_VALUE = nil
|
9
9
|
@HEADER_VALUE = nil
|
10
10
|
|
11
|
+
# Returns the social media post
|
12
|
+
#
|
13
|
+
# ==== Attributes
|
14
|
+
#
|
15
|
+
# * +param_api_uri+ - API end point
|
16
|
+
# * +param_query_hash+ - query hash
|
17
|
+
#
|
18
|
+
# ==== Examples
|
19
|
+
#
|
20
|
+
# +parap_api_uri+
|
21
|
+
#
|
22
|
+
# https://www.company.com:8080/api/endPoint
|
23
|
+
#
|
24
|
+
# +param_query_hash+
|
25
|
+
#
|
26
|
+
# query_values = {
|
27
|
+
# "key1" => "value1",
|
28
|
+
# "key2" => "value2"
|
29
|
+
# }
|
30
|
+
#
|
31
|
+
# ====
|
11
32
|
def getSocialMediaPost(param_api_uri,param_query_hash)
|
12
33
|
@OPTIONS = {query: param_query_hash , headers:@HEADER_VALUE}
|
13
|
-
|
14
|
-
|
15
|
-
return get_result.parsed_response
|
34
|
+
getRequest_result = HTTParty.get(param_api_uri,@OPTIONS)
|
35
|
+
return getRequest_result
|
16
36
|
end
|
17
37
|
|
38
|
+
# API Endpoint Request
|
39
|
+
#
|
40
|
+
# ==== Attributes
|
41
|
+
#
|
42
|
+
# * +param_api_endpoint+ - API endpoint
|
43
|
+
# * +param_header_hash+ - Header hash
|
44
|
+
# * +param_query_hash+ - Query hash
|
45
|
+
#
|
46
|
+
# ==== Return
|
47
|
+
#
|
48
|
+
# * returns get request OBJECT
|
49
|
+
#
|
50
|
+
# ====
|
51
|
+
def getAPI_Request(param_api_endpoint,param_header_hash,param_query_hash)
|
52
|
+
@OPTIONS = {headers: param_header_hash, query: param_query_hash}
|
53
|
+
getRequest_result = HTTParty.get(param_api_endpoint,@OPTIONS)
|
54
|
+
end
|
18
55
|
|
19
56
|
|
57
|
+
# Returns all entities
|
58
|
+
#
|
59
|
+
# ==== Attributes
|
60
|
+
#
|
61
|
+
# * +param_api_uri_+ - API end point
|
62
|
+
#
|
63
|
+
# ==== Return
|
64
|
+
#
|
65
|
+
# * returns get request OBJECT
|
66
|
+
#
|
67
|
+
# ==== Examples
|
68
|
+
#
|
69
|
+
# +parap_api_uri+
|
70
|
+
#
|
71
|
+
# https://www.company.com:8080/api/endPoint
|
72
|
+
#
|
73
|
+
# ====
|
20
74
|
def getAllEntities(param_api_uri)
|
21
75
|
@OPTIONS = {headers:@HEADER_VALUE}
|
22
|
-
|
23
|
-
|
24
|
-
return get_result.parsed_response
|
76
|
+
getRequest_result = HTTParty.get(param_api_uri,@OPTIONS)
|
77
|
+
return getRequest_result
|
25
78
|
end
|
26
79
|
|
80
|
+
# Returns Authentication Token
|
81
|
+
def getToken
|
82
|
+
return @AUTH_TOKEN
|
83
|
+
end
|
27
84
|
|
28
|
-
|
85
|
+
# Authenticate
|
86
|
+
#
|
87
|
+
# ==== Attributes
|
88
|
+
#
|
89
|
+
# * +param_username+ - Username
|
90
|
+
# * +param_password+ - Password
|
91
|
+
# * +param_api_uri+ - API endpoint for authentication
|
92
|
+
#
|
93
|
+
# ==== Return
|
94
|
+
#
|
95
|
+
# * returns TRUE if authentication is successful
|
96
|
+
#
|
97
|
+
# ====
|
29
98
|
def authenticate(param_username,param_password,param_api_uri)
|
30
99
|
@options = {
|
31
100
|
headers: {
|
@@ -44,12 +113,6 @@ class AvrijAnalyticsUtility::APIConnection
|
|
44
113
|
}
|
45
114
|
return !@AUTH_VALUE.nil?
|
46
115
|
end
|
47
|
-
|
48
|
-
def jsonStr_to_jsonFile(param_jsonstring,param_outputfile)
|
49
|
-
File.open(param_outputfile,"w") do |f|
|
50
|
-
f.write(param_jsonstring.to_json)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
116
|
|
117
|
+
|
55
118
|
end
|
@@ -2,11 +2,27 @@ require "AvrijAnalyticsUtility/version"
|
|
2
2
|
require "AvrijAnalyticsUtility/APIConnection"
|
3
3
|
|
4
4
|
module AvrijAnalyticsUtility
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
5
|
+
|
6
|
+
# Get all social media post given from date_1 to date_2
|
7
|
+
#
|
8
|
+
# ==== Attributes
|
9
|
+
#
|
10
|
+
# * +param_username+ - Username
|
11
|
+
# * +param_password+ - Password
|
12
|
+
# * +param_auth_uri+ - Authentication end point
|
13
|
+
# * +param_data_uri+ - API data source end point
|
14
|
+
# * +param_from_datetime+ - From date value
|
15
|
+
# * +param_to_datetime+ - To date value
|
16
|
+
#
|
17
|
+
# ==== Return
|
18
|
+
#
|
19
|
+
# * returns GET request OBJECT
|
20
|
+
#
|
21
|
+
# ==== Notes
|
22
|
+
# * datetime must have the following format : 2017-06-30T00:00:00+04:00
|
23
|
+
#
|
24
|
+
# ====
|
25
|
+
def self.getAllSocialMediaPostfromDateRange(param_username,param_password,param_auth_uri,param_data_uri,param_from_datetime,param_to_datetime)
|
10
26
|
query_values = {
|
11
27
|
"entity" => "All identified",
|
12
28
|
"from" => param_from_datetime,
|
@@ -22,48 +38,42 @@ module AvrijAnalyticsUtility
|
|
22
38
|
puts query_values
|
23
39
|
conn = APIConnection.new
|
24
40
|
conn.authenticate(param_username,param_password,param_auth_uri)
|
25
|
-
|
26
|
-
|
27
|
-
filename = 'AllSocialMediaPost.json'
|
28
|
-
conn.jsonStr_to_jsonFile(response,filename)
|
29
|
-
end
|
30
|
-
return response
|
41
|
+
get_request_object = conn.getSocialMediaPost(param_data_uri,query_values)
|
42
|
+
return get_request_object
|
31
43
|
end
|
32
44
|
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
# Get all entities
|
46
|
+
#
|
47
|
+
# ==== Attributes
|
48
|
+
#
|
49
|
+
# * +param_username+ - Username
|
50
|
+
# * +param_password+ - Password
|
51
|
+
# * +param_auth_uri+ - API endpoint for authentication
|
52
|
+
# * +param_data_uri+ - API endpoint for data request
|
53
|
+
#
|
54
|
+
# ==== Return
|
55
|
+
#
|
56
|
+
# * returns GET request OBJECT
|
57
|
+
#
|
58
|
+
# ====
|
59
|
+
def self.getAllEntities(param_username,param_password,param_auth_uri,param_data_uri)
|
47
60
|
conn = APIConnection.new
|
48
61
|
conn.authenticate(param_username,param_password,param_auth_uri)
|
49
|
-
|
50
|
-
|
51
|
-
filename = 'result_' + param_entity + "_" + param_date +".json"
|
52
|
-
conn.jsonStr_to_jsonFile(response,filename)
|
53
|
-
end
|
54
|
-
return response
|
55
|
-
end
|
56
|
-
|
57
|
-
# GET ENTITIES FROM AN API SOURCE
|
58
|
-
def self.getEntities(param_username,param_password,param_auth_uri,param_data_uri,send_to_file)
|
59
|
-
conn = APIConnection.new
|
60
|
-
conn.authenticate(param_username,param_password,param_auth_uri)
|
61
|
-
response = conn.getAllEntities(param_data_uri)
|
62
|
-
if send_to_file
|
63
|
-
filename = 'result_entities.json'
|
64
|
-
conn.jsonStr_to_jsonFile(response,filename)
|
65
|
-
end
|
66
|
-
return response
|
62
|
+
get_request_object = conn.getAllEntities(param_data_uri)
|
63
|
+
return get_request_object
|
67
64
|
end
|
68
65
|
|
66
|
+
# Writes json string to json file
|
67
|
+
#
|
68
|
+
# ==== Attributes
|
69
|
+
#
|
70
|
+
# * +param_jsonstring+ - json string value
|
71
|
+
# * +param_outputfile+ - json file name
|
72
|
+
#
|
73
|
+
# ====
|
74
|
+
def jsonString_to_json(param_jsonstring,param_outputfile)
|
75
|
+
File.open(param_outputfile,"w") do |f|
|
76
|
+
f.write(param_jsonstring.to_json)
|
77
|
+
end
|
78
|
+
end
|
69
79
|
end
|