Class: InterFAX::Outbound

Inherits:
Object
  • Object
show all
Defined in:
lib/interfax/outbound.rb

Defined Under Namespace

Classes: Delivery, Fax

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Outbound

Returns a new instance of Outbound.



5
6
7
# File 'lib/interfax/outbound.rb', line 5

def initialize client
  @client = client
end

Instance Attribute Details

#deliveryObject



9
10
11
# File 'lib/interfax/outbound.rb', line 9

def delivery
  @delivery ||= InterFAX::Outbound::Delivery.new(@client)
end

Instance Method Details

#all(params = {}) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/interfax/outbound.rb', line 17

def all params = {}
  valid_keys = [:limit, :lastId, :sortOrder, :userId]
  @client.get('/outbound/faxes', params, valid_keys).map do |fax|
    fax[:client] = @client
    InterFAX::Outbound::Fax.new(fax)
  end
end

#cancel(fax_id) ⇒ Object



45
46
47
48
# File 'lib/interfax/outbound.rb', line 45

def cancel fax_id
  fax = @client.post("/outbound/faxes/#{fax_id}/cancel")
  true
end

#completed(*ids) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/interfax/outbound.rb', line 25

def completed *ids
  params = { ids: [ids].flatten }
  valid_keys = [:ids]
  @client.get('/outbound/faxes/completed', params, valid_keys).map do |fax|
    fax[:client] = @client
    InterFAX::Outbound::Fax.new(fax)
  end
end

#deliver(params = {}) ⇒ Object



13
14
15
# File 'lib/interfax/outbound.rb', line 13

def deliver params = {}
  delivery.deliver(params)
end

#find(id) ⇒ Object



34
35
36
37
38
# File 'lib/interfax/outbound.rb', line 34

def find id
  fax = @client.get("/outbound/faxes/#{id}")
  fax[:client] = @client
  InterFAX::Outbound::Fax.new(fax)
end

#image(fax_id) ⇒ Object



40
41
42
43
# File 'lib/interfax/outbound.rb', line 40

def image fax_id
  data, mimeType = @client.get("/outbound/faxes/#{fax_id}/image")
  InterFAX::Image.new(data: data, client: @client, mimeType: mimeType)
end

#search(params = {}) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/interfax/outbound.rb', line 50

def search params = {}
  valid_keys = [:ids, :reference, :dateFrom, :dateTo, :status, :userId, :faxNumber, :limit, :offset]
  @client.get('/outbound/search', params, valid_keys).map do |fax|
    fax[:client] = @client
    InterFAX::Outbound::Fax.new(fax)
  end
end