Method: VerticalResponse::API::Resource.create

Defined in:
lib/verticalresponse/api/resource.rb

.create(params, path_prefix = []) ⇒ Object

Creates a new object of the current class with the parameters provided



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/verticalresponse/api/resource.rb', line 92

def create(params, path_prefix = [])
  access_token = params[:access_token]
  params.delete :access_token

  validate_supported_method!(:create)

  uri = resource_uri_with_prefix(path_prefix)

  # VerticalResponse doesn't like it when we pass the access_token via POST
  uri += (uri.include? "?") ? "&" : "?"
  uri += "access_token=#{access_token}"

  response = Response.new(
    post(uri, build_params(params))
  )
  self.new(response, access_token)
end