transloadit 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/transloadit/assembly.rb +4 -5
- data/lib/transloadit/request.rb +9 -14
- data/lib/transloadit/version.rb +1 -1
- metadata +1 -1
data/lib/transloadit/assembly.rb
CHANGED
@@ -50,16 +50,15 @@ class Transloadit::Assembly
|
|
50
50
|
# @param [Hash] params additional POST data to submit with the request
|
51
51
|
#
|
52
52
|
def submit!(*ios)
|
53
|
-
params
|
53
|
+
params = _extract_options!(*ios)
|
54
|
+
payload = { :params => self.to_hash.update(params) }
|
54
55
|
|
55
|
-
ios.each_with_index
|
56
|
-
params.update "file_#{i}" => f
|
57
|
-
end
|
56
|
+
ios.each_with_index {|f, i| payload.update "file_#{i}" => f }
|
58
57
|
|
59
58
|
request = Transloadit::Request.new '/assemblies',
|
60
59
|
self.transloadit.secret
|
61
60
|
|
62
|
-
request.post(
|
61
|
+
request.post(payload).extend!(Transloadit::Response::Assembly)
|
63
62
|
end
|
64
63
|
|
65
64
|
#
|
data/lib/transloadit/request.rb
CHANGED
@@ -55,14 +55,6 @@ class Transloadit::Request
|
|
55
55
|
self.url.to_s.inspect
|
56
56
|
end
|
57
57
|
|
58
|
-
def to_hash
|
59
|
-
{ :signature => self.signature }.delete_if {|k,v| v.nil? }
|
60
|
-
end
|
61
|
-
|
62
|
-
def to_json
|
63
|
-
self.to_hash.to_json
|
64
|
-
end
|
65
|
-
|
66
58
|
protected
|
67
59
|
|
68
60
|
attr_writer :url
|
@@ -85,11 +77,14 @@ class Transloadit::Request
|
|
85
77
|
end
|
86
78
|
end
|
87
79
|
|
88
|
-
def to_payload(
|
89
|
-
return
|
90
|
-
return
|
80
|
+
def to_payload(payload = nil)
|
81
|
+
return {} if payload.nil?
|
82
|
+
return {} if payload.respond_to?(:empty?) and payload.empty?
|
91
83
|
|
92
|
-
|
84
|
+
# TODO: refactor this, don't update a hash that's not ours
|
85
|
+
payload.update :params => payload[:params].to_json
|
86
|
+
payload.update :signature => self.signature(payload[:params])
|
87
|
+
payload.delete :signature if payload[:signature].nil?
|
93
88
|
end
|
94
89
|
|
95
90
|
def to_query(params = nil)
|
@@ -111,8 +106,8 @@ class Transloadit::Request
|
|
111
106
|
Transloadit::Response.new e.response
|
112
107
|
end
|
113
108
|
|
114
|
-
def signature
|
115
|
-
self.class._hmac(self.secret,
|
109
|
+
def signature(params)
|
110
|
+
self.class._hmac(self.secret, params.to_json) if self.secret
|
116
111
|
end
|
117
112
|
|
118
113
|
private
|
data/lib/transloadit/version.rb
CHANGED