outreach_gem 1.0.64 → 1.0.67

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: 583dff6caf5e5700c26a3766da985bd101e81dfe13ebae98bf93924a91d37d9a
4
- data.tar.gz: a447fcad60f655a2a10ea121edad7c6b9082f85a0a55e19e1a0a8d11a7455907
3
+ metadata.gz: 0f72dc1dff996479f5a0a725ea651a48102a58c16bbbb6377e9e509a54404d73
4
+ data.tar.gz: 252281ca2bccdb707471f400392e4944d0f6dddccb0a6d3f87b29fdf407d0008
5
5
  SHA512:
6
- metadata.gz: a4a529882416d94d0bd19ce7e219d2a633109ca9572967c594d4d0dd33ffa3f7fac5a104c74c0758dfc241a61853861ba5b41313342710c275cfc69f7c7a1a7b
7
- data.tar.gz: 9a956842d3b53f63689e8c1aad159b766071124e2f36edac565a9645116c68199c2ef00cf7c7626963ca33f53d014777f13e4f8449142e705f121c758122656e
6
+ metadata.gz: 7894c74041e00d3367661de5f5e63aafef6406f66c287610c8b453ce8457866f181182685ac4d27d264ab137677d23641d6b929c11fdff21b524a87cb8bacd82
7
+ data.tar.gz: 03aaca9b98badd37c8d56320ad7a9846a622c48a4433ea31684d8081fc69a0589b9080697503ca4917e632f293cad7a7de8503750a7c141814adfa514b74fd93
@@ -2,36 +2,42 @@ require 'aws-sdk-s3'
2
2
 
3
3
  class OutreachUploadS3
4
4
 
5
- # @param key [String] Name of the key used to access AWS
6
- # @param secret [String] Name of the secret key used to access AWS
7
- # @param region [String] Name of the region of the bucket
8
- # @param bucketName [String] Name of the S3 Bucket
9
- def initialize(key, secretKey, region, bucketName)
10
- if secretKey.empty?
11
- raise 'secretKey cannot be empty'
12
- end
5
+ # @param parameters Is an object that represents the parameters for the initialization of this component
6
+ # example of input format:
7
+ # outreachClient = OutreachUploadS3.new(
8
+ # key: ENV['S3_ACCESS_KEY'], [String] Name of the key used to access AWS
9
+ # secretKey: ENV['S3_SECRET_KEY'], [String] Name of the secret key used to access AWS
10
+ # region: 'us-west-2', [String] Name of the region of the bucket
11
+ # bucketName: 'fb3e8922-fcb9-4042-b9f3-3f041602b5d3' [String] Name of the S3 Bucket
12
+ # )
13
13
 
14
- if key.empty?
14
+ def initialize(parameters)
15
+ if parameters.fetch(:key, nil).nil?
15
16
  raise 'key cannot be empty'
16
17
  end
18
+
19
+ if parameters.fetch(:secretKey, nil).nil?
20
+ raise 'secretKey cannot be empty'
21
+ end
17
22
 
18
- if region.empty?
23
+ if parameters.fetch(:region, nil).nil?
19
24
  raise 'region cannot be empty'
20
25
  end
21
26
 
22
- if bucketName.empty?
27
+ if parameters.fetch(:bucketName, nil).nil?
23
28
  raise 'bucketName cannot be empty'
24
29
  end
25
- @region = region
26
- @bucketName = bucketName
30
+
31
+ @region = parameters.fetch(:region)
32
+ @bucketName = parameters.fetch(:bucketName)
27
33
 
28
34
  Aws.config.update({
29
- credentials: Aws::Credentials.new(key, secretKey)
35
+ credentials: Aws::Credentials.new(parameters.fetch(:key), parameters.fetch(:secretKey))
30
36
  })
31
37
  @s3_client = Aws::S3::Client.new({
32
38
  region: @region,
33
- access_key_id: key,
34
- secret_access_key: secretKey
39
+ access_key_id: parameters.fetch(:key),
40
+ secret_access_key: parameters.fetch(:secretKey)
35
41
  })
36
42
  end
37
43
 
@@ -7,35 +7,58 @@ require_relative 'resttype'
7
7
  class RestClient
8
8
 
9
9
  # Initalize the object to perform the operations
10
- # @param uri [String] The URL to perform the request against
11
- # @param headers [Hash] Object that resembles the following structure
12
- # {
13
- # 'Content-Type' => 'application/json'
14
- # }
15
- # @param rest_type [resttype] Module that defines the type of operation that we are about to perform
16
- # @param ssl [Boolean] True -> SSL is enabled. False -> SSL is disabled
17
- # @param params [Hash] Is an object that represents the query string parameters to assign to the URL within the give
10
+ # @param parameters [Hash] Is an object that represents the parameters for the initialization of this component
18
11
  # restful invocation {'state' => 'started'}
19
- def initialize(uri, headers, rest_type, ssl, params)
20
- @uri = URI(uri)
12
+ # example of input format:
13
+ # RestClient.new(
14
+ # uri: 'https://api.travis-ci.com/repo/AES-Outreach%2FForms-Application/builds', ([String] The URL to perform the request against)
15
+ # headers: { [Hash] Object that resembles the following structure
16
+ # 'Content-Type' => 'application/json'
17
+ # },
18
+ # rest_type: RestTypes::GET, [resttype] Module that defines the type of operation that we are about to perform
19
+ # ssl: true, [Boolean] True -> SSL is enabled. False -> SSL is disabled
20
+ # params: {'state' => 'started'} [Hash] Is an object that represents the query string parameters to assign to the URL within the give
21
+ # )
22
+
23
+
24
+ def initialize(parameters)
25
+
26
+ if parameters.fetch(:uri, nil).nil?
27
+ raise 'uri cannot be empty'
28
+ end
29
+
30
+ if parameters.fetch(:headers, nil).nil?
31
+ raise 'headers cannot be empty'
32
+ end
33
+
34
+ if parameters.fetch(:rest_type, nil).nil?
35
+ raise 'rest_type cannot be empty'
36
+ end
37
+
38
+ if parameters.fetch(:ssl, nil).nil?
39
+ raise 'ssl cannot be empty'
40
+ end
41
+
42
+
43
+ @uri = URI(parameters.fetch(:uri))
21
44
  @http = Net::HTTP.new(@uri.host, @uri.port)
22
45
 
23
- if ssl === true
46
+ if parameters.fetch(:ssl) === true
24
47
  @http.use_ssl = true
25
48
  end
26
49
 
27
- if params.nil?
28
- if RestTypes::POST === rest_type
29
- @req = Net::HTTP::Post.new(@uri.path, headers)
30
- elsif RestTypes::GET === rest_type
31
- @req = Net::HTTP::Get.new(@uri.path, headers)
50
+ if parameters.fetch(:params, nil).nil?
51
+ if RestTypes::POST === parameters.fetch(:rest_type)
52
+ @req = Net::HTTP::Post.new(@uri.path, parameters.fetch(:headers))
53
+ elsif RestTypes::GET === parameters.fetch(:rest_type)
54
+ @req = Net::HTTP::Get.new(@uri.path, parameters.fetch(:headers))
32
55
  end
33
56
  else
34
- @uri.query = URI.encode_www_form( params )
35
- if RestTypes::POST === rest_type
36
- @req = Net::HTTP::Post.new(@uri.path + '?' + @uri.query, headers)
37
- elsif RestTypes::GET === rest_type
38
- @req = Net::HTTP::Get.new(@uri.path + '?' + @uri.query, headers)
57
+ @uri.query = URI.encode_www_form(parameters.fetch(:params))
58
+ if RestTypes::POST === parameters.fetch(:rest_type)
59
+ @req = Net::HTTP::Post.new(@uri.path + '?' + @uri.query, parameters.fetch(:headers))
60
+ elsif RestTypes::GET === parameters.fetch(:rest_type)
61
+ @req = Net::HTTP::Get.new(@uri.path + '?' + @uri.query, parameters.fetch(:headers))
39
62
  end
40
63
  end
41
64
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outreach_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.64
4
+ version: 1.0.67
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrique Legault
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-12 00:00:00.000000000 Z
11
+ date: 2019-06-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: patrique.legault@uottawa.ca