AvrijAnalyticsUtility 0.2.5 → 0.2.6

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
  SHA1:
3
- metadata.gz: 42b55c3510396745ec136f294a33fefbc9c41de5
4
- data.tar.gz: 4305c3b17c0b1b49901c6034fe8ce0012e4a1d5d
3
+ metadata.gz: f6360dbe36f72a703e62c4e2dd49609ce7f5fd9a
4
+ data.tar.gz: 467a95abff98dba3a60e1db4e202097bf6c20aaa
5
5
  SHA512:
6
- metadata.gz: b755c6ed6106f4ca369d623959af88a5878f44a5d6714601ede1769504c0f478fced71013c0582e5ca2d7286a446239b415ca47007a15f8678cd497102abe15f
7
- data.tar.gz: 1cc03dc82d1447af8d280887ee064afd4012c8e4a3e0c845fb6f93d1b6044789f7e6bf778e62ddaa7558f6ca6160d1988e253a088f331cd18a32847596e67d8a
6
+ metadata.gz: 8db5386a39a4d64e0fd4f29a9f345e2f96c417e1897720b7fa5c1203d585a81e74f16aff5c222e56a2bc2fcfa921e906a864d423c45354fafe1cfc0cb88ced0c
7
+ data.tar.gz: d45a02fae80ab38a4394e2f3589da13e65d4ca1f8d21c73414cb37ab690bb9b61a9b061e8eec4185d79a9968f2386e3b37ae6733a21a463af7338205db54341b
data/Rakefile CHANGED
@@ -14,3 +14,4 @@ task :release do
14
14
  end
15
15
 
16
16
 
17
+
@@ -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
- get_result = HTTParty.get(param_api_uri,@OPTIONS)
14
- puts get_result.request.last_uri.to_s
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
- get_result = HTTParty.get(param_api_uri,@OPTIONS)
23
- puts get_result.request.last_uri.to_s
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
- #----------- Private Methods --------------
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
@@ -1,3 +1,3 @@
1
1
  module AvrijAnalyticsUtility
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -2,11 +2,27 @@ require "AvrijAnalyticsUtility/version"
2
2
  require "AvrijAnalyticsUtility/APIConnection"
3
3
 
4
4
  module AvrijAnalyticsUtility
5
-
6
-
7
- #GET ALL SOCIAL MEDIA POST
8
- # datetime must have the following format : 2017-06-30T00:00:00+04:00
9
- def self.getAllSocialMediaPostfromDateRange(param_username,param_password,param_auth_uri,param_data_uri,param_from_datetime,param_to_datetime,send_to_file)
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
- response = conn.getSocialMediaPost(param_data_uri,query_values)
26
- if send_to_file
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
- #GET SOCIAL MEDIA POST GIVEN THE ENTITY NAME AND DATE
34
- def self.getSocialMediaPost(param_username,param_password,param_auth_uri,param_data_uri,param_entity,param_date,send_to_file)
35
- query_values = {
36
- "entity"=> param_entity,
37
- "from" => param_date,
38
- "to" => param_date,
39
- "facebook" => "0",
40
- "facebookPost" => "0",
41
- "reddit"=>"0",
42
- "youtube" => "0",
43
- "youtubeComment"=>"0",
44
- "twitter" => "0",
45
- "news" => "0"
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
- response = conn.getSocialMediaPost(param_data_uri,query_values)
50
- if send_to_file
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: AvrijAnalyticsUtility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dalisay