Class: Postful::Order

Inherits:
Object
  • Object
show all
Includes:
InstanceExecModule, Util
Defined in:
lib/postful/order.rb

Overview

Represent a Postful order.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InstanceExecModule

#instance_exec

Instance Attribute Details

#addresseesObject (readonly)

Returns the value of attribute addressees.



20
21
22
# File 'lib/postful/order.rb', line 20

def addressees
  @addressees
end

#errorsObject (readonly)

Returns the value of attribute errors.



23
24
25
# File 'lib/postful/order.rb', line 23

def errors
  @errors
end

#historyObject (readonly)

Returns the value of attribute history.



19
20
21
# File 'lib/postful/order.rb', line 19

def history
  @history
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/postful/order.rb', line 10

def id
  @id
end

#pagesObject (readonly)

Returns the value of attribute pages.



13
14
15
# File 'lib/postful/order.rb', line 13

def pages
  @pages
end

#preview_urlObject (readonly)

Returns the value of attribute preview_url.



14
15
16
# File 'lib/postful/order.rb', line 14

def preview_url
  @preview_url
end

#priceObject (readonly)

Returns the value of attribute price.



15
16
17
# File 'lib/postful/order.rb', line 15

def price
  @price
end

#return_addressObject (readonly)

Returns the value of attribute return_address.



22
23
24
# File 'lib/postful/order.rb', line 22

def return_address
  @return_address
end

#sourceObject (readonly)

Returns the value of attribute source.



12
13
14
# File 'lib/postful/order.rb', line 12

def source
  @source
end

#statusObject (readonly)

Returns the value of attribute status.



11
12
13
# File 'lib/postful/order.rb', line 11

def status
  @status
end

#tag1Object (readonly)

Returns the value of attribute tag1.



16
17
18
# File 'lib/postful/order.rb', line 16

def tag1
  @tag1
end

#tag2Object (readonly)

Returns the value of attribute tag2.



17
18
19
# File 'lib/postful/order.rb', line 17

def tag2
  @tag2
end

#tag3Object (readonly)

Returns the value of attribute tag3.



18
19
20
# File 'lib/postful/order.rb', line 18

def tag3
  @tag3
end

#warningsObject (readonly)

Returns the value of attribute warnings.



21
22
23
# File 'lib/postful/order.rb', line 21

def warnings
  @warnings
end

Instance Method Details

#cancelObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/postful/order.rb', line 42

def cancel
  response = delete_request_on_path("/service/mail/#{id}", @email, @password)
  case response.code
    when "200" then
      build_from_response(response.body)
    when "422" then
      raise Postful::ValidationException, build_error_message_from_response(response.body)          
    else
      process_standard_responses(response)
  end                 
end

#previewObject



27
28
29
30
# File 'lib/postful/order.rb', line 27

def preview    
  url = URI.parse(preview_url)
  url.read
end

#refreshObject



32
33
34
35
36
37
38
39
40
# File 'lib/postful/order.rb', line 32

def refresh
  response = get_request_on_path("/service/mail/#{id}", @email, @password)
  case response.code
    when "200" then
      build_from_response(response.body)
    else
      process_standard_responses(response)
  end                 
end