22require "date"
33require "json"
44require "openssl"
5- require "uri"
65require "cgi"
76
87#
@@ -31,7 +30,6 @@ class Transloadit
3130 attr_accessor :duration
3231
3332 attr_accessor :max_size
34- attr_accessor :service
3533
3634 #
3735 # Creates a new instance of the Transloadit API.
@@ -49,7 +47,6 @@ def initialize(options = {})
4947 self . secret = options [ :secret ]
5048 self . duration = options [ :duration ] || 5 * 60
5149 self . max_size = options [ :max_size ]
52- self . service = _normalize_service ( options [ :service ] ) || _service_from_region ( options [ :region ] )
5350
5451 _ensure_key_provided
5552 end
@@ -110,7 +107,7 @@ def bill(month = Date.today.month, year = Date.today.year)
110107 month = format "%02d" , month
111108 path = "bill/#{ year } -#{ month } "
112109
113- Transloadit ::Request . new ( request_url_for ( path ) , secret ) . get ( { auth : to_hash } )
110+ Transloadit ::Request . new ( path , secret ) . get ( { auth : to_hash } )
114111 end
115112
116113 #
@@ -137,22 +134,6 @@ def to_json
137134 MultiJson . dump ( to_hash )
138135 end
139136
140- #
141- # Resolves an absolute URL for API requests, honoring custom service overrides.
142- #
143- # @param [String] path the request path or URL
144- # @return [String] the resolved URL or original path if already absolute
145- #
146- def request_url_for ( path )
147- return path if service . nil? || service . empty?
148-
149- uri = URI . parse ( path . to_s )
150- return path if uri . host
151-
152- base = service . end_with? ( "/" ) ? service : "#{ service } /"
153- URI . join ( base , path . to_s . sub ( %r{\A /} , "" ) ) . to_s
154- end
155-
156137 # @param workspace [String] Workspace slug
157138 # @param template [String] Template slug or template ID
158139 # @param input [String] Input value that is provided as `${fields.input}` in the template
@@ -203,30 +184,6 @@ def signed_smart_cdn_url(
203184
204185 private
205186
206- #
207- # Normalizes service URLs, returning nil for blank values.
208- #
209- def _normalize_service ( value )
210- return nil if value . nil?
211-
212- str = value . to_s . strip
213- return nil if str . empty?
214-
215- str
216- end
217-
218- #
219- # Builds a service URL from a region hint, if one is provided.
220- #
221- def _service_from_region ( region )
222- return nil if region . nil?
223-
224- str = region . to_s . strip
225- return nil if str . empty?
226-
227- "https://api2-#{ str } .transloadit.com"
228- end
229-
230187 #
231188 # Raises an ArgumentError if no {#key} has been assigned.
232189 #
0 commit comments