Class: Xfrtuc::Transfer
- Inherits:
-
ApiEndpoint
- Object
- ApiEndpoint
- Xfrtuc::Transfer
- Defined in:
- lib/xfrtuc.rb
Instance Method Summary collapse
- #cancel(id) ⇒ Object
- #create(opts) ⇒ Object
- #delete(id) ⇒ Object
- #info(id, opts = {}) ⇒ Object
-
#initialize(client) ⇒ Transfer
constructor
A new instance of Transfer.
- #list ⇒ Object
- #public_url(id, opts = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Transfer
Returns a new instance of Transfer.
84 |
# File 'lib/xfrtuc.rb', line 84 def initialize(client); super; end |
Instance Method Details
#cancel(id) ⇒ Object
129 130 131 |
# File 'lib/xfrtuc.rb', line 129 def cancel(id) client.post("/transfers/#{CGI.escape(id)}/actions/cancel") end |
#create(opts) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/xfrtuc.rb', line 98 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.merge!(log_input_url: log_input_url) unless log_input_url.nil? payload.merge!(num_keep: num_keep) unless num_keep.nil? client.post("/transfers", payload) end |
#delete(id) ⇒ Object
125 126 127 |
# File 'lib/xfrtuc.rb', line 125 def delete(id) client.delete("/transfers/#{CGI.escape(id)}") end |
#info(id, opts = {}) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/xfrtuc.rb', line 86 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 |
#list ⇒ Object
94 95 96 |
# File 'lib/xfrtuc.rb', line 94 def list client.get("/transfers") end |
#public_url(id, opts = {}) ⇒ Object
133 134 135 |
# File 'lib/xfrtuc.rb', line 133 def public_url(id, opts={}) client.post("/transfers/#{CGI.escape(id)}/actions/public-url", opts) end |