cloud_elements 0.2.1 → 0.2.2
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/cloud_elements.rb +13 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c49ee5f7e77a2cb6e3069a88823d5eaae944177
|
4
|
+
data.tar.gz: 6fd5050c187d4f9058cb4ce9a4cc309af7e4a0ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 109ad9e4b83429e23d4e18e182fc644bf4eae60cd4a75a8418d3e28ca4177c51035a86751e6aa1456b6f4624a76fc2d915d56351f9abe3403b2866d8643b2418
|
7
|
+
data.tar.gz: e1ad9afd753fbfb205413cfee69912bc777b786b5ccedf56bf1587f5ec5874374b9c184d83bf875d180098daa1d9dd4f532cf6945798b9d1cb1c7713cf7351bc
|
data/lib/cloud_elements.rb
CHANGED
@@ -6,9 +6,13 @@ All connections are made through the invoke method.
|
|
6
6
|
It utilized HTTMultiParty to make http requests.
|
7
7
|
=end
|
8
8
|
class ElementsConnector
|
9
|
+
|
10
|
+
attr_accessor :api_endpoint
|
11
|
+
|
9
12
|
def initialize(api_endpoint='https://console.cloud-elements.com/elements/api-v1')
|
10
13
|
@api_endpoint = api_endpoint # Endpoint to hit the api. Defaults to production
|
11
14
|
@headers = Hash.new # Headers for some requests
|
15
|
+
@headers['Content-Type'] = 'application-json'
|
12
16
|
end
|
13
17
|
|
14
18
|
private
|
@@ -28,7 +32,9 @@ class ElementsConnector
|
|
28
32
|
when 'post'
|
29
33
|
if files
|
30
34
|
files.each { |f| params[f] = File.new(f) }
|
35
|
+
@headers.delete(['Content-Type'])
|
31
36
|
response = HTTMultiParty.post(@url, :headers => @headers, :query => params)
|
37
|
+
@headers['Content-Type'] = 'application-json'
|
32
38
|
else
|
33
39
|
response = HTTMultiParty.post(@url, :headers => @headers, :body => params.to_json)
|
34
40
|
end
|
@@ -40,9 +46,14 @@ class ElementsConnector
|
|
40
46
|
|
41
47
|
# This method allows users to interact with the Elements API.
|
42
48
|
# It is essentially a copy of the Java ElementsConnector class.
|
43
|
-
def invoke(httpMethod, providerName,
|
49
|
+
def invoke(httpMethod, providerName, headers, apiMethodName, params=nil, files=nil, providerVersion='1')
|
44
50
|
@url = "#{@api_endpoint}/#{providerName}/#{providerVersion}/#{apiMethodName}"
|
45
|
-
|
51
|
+
if headers.class() == Hash
|
52
|
+
auth_string = "User #{headers[:user_secret]}, Organization #{headers[:organization_secret]}"
|
53
|
+
else
|
54
|
+
auth_string = "Element #{headers}"
|
55
|
+
end
|
56
|
+
@headers['Authorization'] = auth_string
|
46
57
|
return request(httpMethod, params, files)
|
47
58
|
end
|
48
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_elements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Rodriguez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httmultiparty
|