Class: Postmark::AccountApiClient

Inherits:
Client
  • Object
show all
Defined in:
lib/postmark/account_api_client.rb

Instance Attribute Summary

Attributes inherited from Client

#http_client, #max_retries

Instance Method Summary collapse

Methods inherited from Client

#api_token=, #find_each

Constructor Details

#initialize(api_token, options = {}) ⇒ AccountApiClient

Returns a new instance of AccountApiClient.



5
6
7
8
9
# File 'lib/postmark/account_api_client.rb', line 5

def initialize(api_token, options = {})
  options = options.dup
  options[:auth_header_name] = 'X-Postmark-Account-Token'
  super
end

Instance Method Details

#create_domain(attributes = {}) ⇒ Object



81
82
83
84
85
# File 'lib/postmark/account_api_client.rb', line 81

def create_domain(attributes = {})
  data = serialize(HashHelper.to_postmark(attributes))

  format_response http_client.post('domains', data)
end

#create_sender(attributes = {}) ⇒ Object Also known as: create_signature



31
32
33
34
35
# File 'lib/postmark/account_api_client.rb', line 31

def create_sender(attributes = {})
  data = serialize(HashHelper.to_postmark(attributes))

  format_response http_client.post('senders', data)
end

#create_server(attributes = {}) ⇒ Object



129
130
131
132
# File 'lib/postmark/account_api_client.rb', line 129

def create_server(attributes = {})
  data = serialize(HashHelper.to_postmark(attributes))
  format_response http_client.post('servers', data)
end

#delete_domain(id) ⇒ Object



109
110
111
# File 'lib/postmark/account_api_client.rb', line 109

def delete_domain(id)
  format_response http_client.delete("domains/#{id.to_i}")
end

#delete_sender(id) ⇒ Object Also known as: delete_signature



60
61
62
# File 'lib/postmark/account_api_client.rb', line 60

def delete_sender(id)
  format_response http_client.delete("senders/#{id.to_i}")
end

#delete_server(id) ⇒ Object



139
140
141
# File 'lib/postmark/account_api_client.rb', line 139

def delete_server(id)
  format_response http_client.delete("servers/#{id.to_i}")
end

#domains(options = {}) ⇒ Object



65
66
67
# File 'lib/postmark/account_api_client.rb', line 65

def domains(options = {})
  find_each('domains', 'Domains', options)
end

#get_data_removal_status(id) ⇒ Object



149
150
151
# File 'lib/postmark/account_api_client.rb', line 149

def get_data_removal_status(id)
  format_response(http_client.get("data-removals/#{id}"))
end

#get_domain(id) ⇒ Object



77
78
79
# File 'lib/postmark/account_api_client.rb', line 77

def get_domain(id)
  format_response http_client.get("domains/#{id.to_i}")
end

#get_domains(options = {}) ⇒ Object



69
70
71
# File 'lib/postmark/account_api_client.rb', line 69

def get_domains(options = {})
  load_batch('domains', 'Domains', options).last
end

#get_domains_count(options = {}) ⇒ Object



73
74
75
# File 'lib/postmark/account_api_client.rb', line 73

def get_domains_count(options = {})
  get_resource_count('domains', options)
end

#get_sender(id) ⇒ Object Also known as: get_signature



26
27
28
# File 'lib/postmark/account_api_client.rb', line 26

def get_sender(id)
  format_response http_client.get("senders/#{id.to_i}")
end

#get_senders(options = {}) ⇒ Object Also known as: get_signatures



16
17
18
# File 'lib/postmark/account_api_client.rb', line 16

def get_senders(options = {})
  load_batch('senders', 'SenderSignatures', options).last
end

#get_senders_count(options = {}) ⇒ Object Also known as: get_signatures_count



21
22
23
# File 'lib/postmark/account_api_client.rb', line 21

def get_senders_count(options = {})
  get_resource_count('senders', options)
end

#get_server(id) ⇒ Object



125
126
127
# File 'lib/postmark/account_api_client.rb', line 125

def get_server(id)
  format_response http_client.get("servers/#{id.to_i}")
end

#get_servers(options = {}) ⇒ Object



117
118
119
# File 'lib/postmark/account_api_client.rb', line 117

def get_servers(options = {})
  load_batch('servers', 'Servers', options).last
end

#get_servers_count(options = {}) ⇒ Object



121
122
123
# File 'lib/postmark/account_api_client.rb', line 121

def get_servers_count(options = {})
  get_resource_count('servers', options)
end

#push_templates(attributes = {}) ⇒ Object



143
144
145
146
147
# File 'lib/postmark/account_api_client.rb', line 143

def push_templates(attributes = {})
  data = serialize(HashHelper.to_postmark(attributes))
  _, batch = format_batch_response(http_client.put('templates/push', data), "Templates")
  batch
end

#request_data_removal(attributes = {}) ⇒ Object



153
154
155
156
# File 'lib/postmark/account_api_client.rb', line 153

def request_data_removal(attributes = {})
  data = serialize(HashHelper.to_postmark(attributes))
  format_response(http_client.post('data-removals', data))
end

#request_new_sender_dkim(id) ⇒ Object Also known as: request_new_signature_dkim



55
56
57
# File 'lib/postmark/account_api_client.rb', line 55

def request_new_sender_dkim(id)
  format_response http_client.post("senders/#{id.to_i}/requestnewdkim")
end

#resend_sender_confirmation(id) ⇒ Object Also known as: resend_signature_confirmation



45
46
47
# File 'lib/postmark/account_api_client.rb', line 45

def resend_sender_confirmation(id)
  format_response http_client.post("senders/#{id.to_i}/resend")
end

#rotate_domain_dkim(id) ⇒ Object



105
106
107
# File 'lib/postmark/account_api_client.rb', line 105

def rotate_domain_dkim(id)
  format_response http_client.post("domains/#{id.to_i}/rotatedkim")
end

#senders(options = {}) ⇒ Object Also known as: signatures



11
12
13
# File 'lib/postmark/account_api_client.rb', line 11

def senders(options = {})
  find_each('senders', 'SenderSignatures', options)
end

#servers(options = {}) ⇒ Object



113
114
115
# File 'lib/postmark/account_api_client.rb', line 113

def servers(options = {})
  find_each('servers', 'Servers', options)
end

#update_domain(id, attributes = {}) ⇒ Object



87
88
89
90
91
# File 'lib/postmark/account_api_client.rb', line 87

def update_domain(id, attributes = {})
  data = serialize(HashHelper.to_postmark(attributes))

  format_response http_client.put("domains/#{id.to_i}", data)
end

#update_sender(id, attributes = {}) ⇒ Object Also known as: update_signature



38
39
40
41
42
# File 'lib/postmark/account_api_client.rb', line 38

def update_sender(id, attributes = {})
  data = serialize(HashHelper.to_postmark(attributes))

  format_response http_client.put("senders/#{id.to_i}", data)
end

#update_server(id, attributes = {}) ⇒ Object



134
135
136
137
# File 'lib/postmark/account_api_client.rb', line 134

def update_server(id, attributes = {})
  data = serialize(HashHelper.to_postmark(attributes))
  format_response http_client.put("servers/#{id.to_i}", data)
end

#verified_domain_spf?(id) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/postmark/account_api_client.rb', line 101

def verified_domain_spf?(id)
  !!http_client.post("domains/#{id.to_i}/verifyspf")['SPFVerified']
end

#verified_sender_spf?(id) ⇒ Boolean Also known as: verified_signature_spf?

Returns:

  • (Boolean)


50
51
52
# File 'lib/postmark/account_api_client.rb', line 50

def verified_sender_spf?(id)
  !!http_client.post("senders/#{id.to_i}/verifyspf")['SPFVerified']
end

#verify_domain_dkim(id) ⇒ Object



93
94
95
# File 'lib/postmark/account_api_client.rb', line 93

def verify_domain_dkim(id)
  format_response http_client.put("domains/#{id.to_i}/verifydkim")
end

#verify_domain_return_path(id) ⇒ Object



97
98
99
# File 'lib/postmark/account_api_client.rb', line 97

def verify_domain_return_path(id)
  format_response http_client.put("domains/#{id.to_i}/verifyreturnpath")
end