transloadit 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 = self.to_hash.update _extract_options!(*ios)
53
+ params = _extract_options!(*ios)
54
+ payload = { :params => self.to_hash.update(params) }
54
55
 
55
- ios.each_with_index do |f, i|
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(params).extend!(Transloadit::Response::Assembly)
61
+ request.post(payload).extend!(Transloadit::Response::Assembly)
63
62
  end
64
63
 
65
64
  #
@@ -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(params = nil)
89
- return self.to_hash if params.nil?
90
- return self.to_hash if params.respond_to?(:empty?) and params.empty?
80
+ def to_payload(payload = nil)
81
+ return {} if payload.nil?
82
+ return {} if payload.respond_to?(:empty?) and payload.empty?
91
83
 
92
- self.to_hash.update(:params => params.to_json)
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, self.params.to_json) if 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
@@ -1,4 +1,4 @@
1
1
  class Transloadit
2
2
  # The current version of Transloadit.
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: transloadit
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Stephen