Skip to content

Commit

Permalink
Add function for creating a license, untested
Browse files Browse the repository at this point in the history
  • Loading branch information
Don Goodman-Wilson committed Jun 10, 2016
1 parent 25df8b9 commit 2fc42e5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/dev_mate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,23 @@ def self.UpdateCustomer(customer)
response_object = JSON.parse response.body
return response_object['data']
end

def self.CreateLicense(customer, licenseId)
data = { :data => { :license_type_id => licenseId } }
response = self.post("/customers/#{id}/licenses", :body => data.to_json, :headers => { "Authorization" => @@auth_header })

unless response.code == 201
#sad path
errors = response_object["errors"]

case response.code
when 400
raise BadRequestError, "#{errors[0]["title"]} #{errors[0]["detail"]}"
end
end

# return response.body on success
response_object = JSON.parse response.body
return response_object['data']
end
end

0 comments on commit 2fc42e5

Please sign in to comment.