Class: AFHTTPSessionManager

Inherits:
Object
  • Object
show all
Includes:
AFMotion::ClientShared, AFMotion::Serialization
Defined in:
lib/afmotion/ext/AFHTTPSessionManager.rb

Instance Method Summary collapse

Methods included from AFMotion::ClientShared

#all_headers, #authorization=, #create_multipart_task, #create_task, #failure_block, #headers, #multipart_post, #multipart_put, #success_block_for_http_method

Methods included from AFMotion::Serialization

#http!, #image!, #json!, #plist!, #with_request_serializer, #with_response_serializer, #xml!

Instance Method Details

#PUT(url_string, options = {}) ⇒ Object

options = , constructingBodyWithBlock: , success:, failure:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/afmotion/ext/AFHTTPSessionManager.rb', line 52

def PUT(url_string, options = {})
  parameters = options[:parameters]
  block = options[:constructingBodyWithBlock]
  progress = options[:progress_block]
  success = options[:success]
  failure = options[:failure]

  request = self.requestSerializer.multipartFormRequestWithMethod("PUT", URLString: NSURL.URLWithString(url_string, relativeToURL: self.baseURL).absoluteString, parameters:parameters, constructingBodyWithBlock:block, error:nil)

  task = self.dataTaskWithRequest(request, uploadProgress: progress, downloadProgress: nil, completionHandler: ->(response, responseObject, error) {
    if error && failure
    failure.call(task, error)
    elsif success
    success.call(task, responseObject)
    end
  })

  task.resume

  task
end