Class: TicketSharing::Agreement

Inherits:
Base
  • Object
show all
Defined in:
lib/ticket_sharing/agreement.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#as_json, field_list, #field_list, fields, first_ancestor, #initialize, #to_json

Constructor Details

This class inherits a constructor from TicketSharing::Base

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



11
12
13
# File 'lib/ticket_sharing/agreement.rb', line 11

def response
  @response
end

Class Method Details

.parse(json) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/ticket_sharing/agreement.rb', line 13

def self.parse(json)
  attributes = JsonSupport.decode(json)
  agreement = new(attributes)
  if agreement.current_actor
    agreement.current_actor = TicketSharing::Actor.new(agreement.current_actor)
  end
  agreement
end

Instance Method Details

#authentication_tokenObject



40
41
42
# File 'lib/ticket_sharing/agreement.rb', line 40

def authentication_token
  "#{uuid}:#{access_key}"
end

#relative_urlObject



36
37
38
# File 'lib/ticket_sharing/agreement.rb', line 36

def relative_url
  '/agreements/' + uuid.to_s
end

#send_to(url) ⇒ Object



22
23
24
25
26
27
# File 'lib/ticket_sharing/agreement.rb', line 22

def send_to(url)
  client = Client.new(url)
  @response = client.post(relative_url, self.to_json)

  @response.status
end

#update_partner(url) ⇒ Object



29
30
31
32
33
34
# File 'lib/ticket_sharing/agreement.rb', line 29

def update_partner(url)
  client = Client.new(url, authentication_token)
  @response = client.put(relative_url, self.to_json)

  @response.status
end