Class: Vng::Case
- Inherits:
-
Object
- Object
- Vng::Case
- Defined in:
- lib/vng/case.rb
Overview
Provides methods to interact with Vonigo cases.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(id:) ⇒ Case
constructor
A new instance of Case.
Constructor Details
#initialize(id:) ⇒ Case
Returns a new instance of Case.
6 7 8 |
# File 'lib/vng/case.rb', line 6 def initialize(id:) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/vng/case.rb', line 4 def id @id end |
Class Method Details
.create(client_id:, summary:, comments:) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vng/case.rb', line 10 def self.create(client_id:, summary:, comments:) body = { securityToken: Vng.configuration.security_token, method: '3', objectID: client_id, Fields: [ {fieldID: 219, optionID: 239}, # Status: open {fieldID: 220, fieldValue: summary}, {fieldID: 230, fieldValue: comments}, ] } uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Cases/' request = Net::HTTP::Post.new(uri.request_uri) request.initialize_http_header 'Content-Type' => 'application/json' request.body = body.to_json response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| http.request request end new id: JSON(response.body)['Case']['objectID'] end |
Instance Method Details
#destroy ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vng/case.rb', line 35 def destroy body = { securityToken: Vng.configuration.security_token, method: '4', objectID: id, } uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/data/Cases/' request = Net::HTTP::Post.new(uri.request_uri) request.initialize_http_header 'Content-Type' => 'application/json' request.body = body.to_json response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| http.request request end end |