Class: Xfrtuc::Transfer

Inherits:
ApiEndpoint show all
Defined in:
lib/xfrtuc.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Transfer

Returns a new instance of Transfer.



134
135
136
# File 'lib/xfrtuc.rb', line 134

def initialize(client)
  super
end

Instance Method Details

#cancel(id) ⇒ Object



181
182
183
# File 'lib/xfrtuc.rb', line 181

def cancel(id)
  client.post("/transfers/#{CGI.escape(id)}/actions/cancel")
end

#create(opts) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/xfrtuc.rb', line 150

def create(opts)
  from_type = opts.fetch :from_type
  from_url = opts.fetch :from_url
  to_type = opts.fetch :to_type
  to_url = opts.fetch :to_url
  [:from_type, :from_url, :to_type, :to_url].each { |key| opts.delete key }
  from_name = opts.delete :from_name
  to_name = opts.delete :to_name
  log_input_url = opts.delete :log_input_url
  num_keep = opts.delete :num_keep

  unless opts.empty?
    raise ArgumentError, "Unsupported option(s): #{opts.keys}"
  end
  payload = {
    from_type: from_type,
    from_url: from_url,
    from_name: from_name,
    to_type: to_type,
    to_url: to_url,
    to_name: to_name,
  }
  payload[:log_input_url] = log_input_url unless log_input_url.nil?
  payload[:num_keep] = num_keep unless num_keep.nil?
  client.post("/transfers", payload)
end

#delete(id) ⇒ Object



177
178
179
# File 'lib/xfrtuc.rb', line 177

def delete(id)
  client.delete("/transfers/#{CGI.escape(id)}")
end

#info(id, opts = {}) ⇒ Object



138
139
140
141
142
143
144
# File 'lib/xfrtuc.rb', line 138

def info(id, opts = {})
  verbose = opts.delete(:verbose) || false
  unless opts.empty?
    raise ArgumentError, "Unsupported option(s): #{opts.keys}"
  end
  client.get("/transfers/#{id}", params: { verbose: verbose })
end

#listObject



146
147
148
# File 'lib/xfrtuc.rb', line 146

def list
  client.get("/transfers")
end

#public_url(id, opts = {}) ⇒ Object



185
186
187
# File 'lib/xfrtuc.rb', line 185

def public_url(id, opts = {})
  client.post("/transfers/#{CGI.escape(id)}/actions/public-url", opts)
end