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
# File 'lib/postmark/account_api_client.rb', line 5

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

Instance Method Details

#create_domain(attributes = {}) ⇒ Object



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

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



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

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

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

#create_server(attributes = {}) ⇒ Object



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

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

#delete_domain(id) ⇒ Object



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

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

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



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

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

#delete_server(id) ⇒ Object



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

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

#domains(options = {}) ⇒ Object



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

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

#get_data_removal_status(id) ⇒ Object



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

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

#get_domain(id) ⇒ Object



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

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

#get_domains(options = {}) ⇒ Object



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

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

#get_domains_count(options = {}) ⇒ Object



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

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

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



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

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

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



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

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

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



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

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

#get_server(id) ⇒ Object



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

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

#get_servers(options = {}) ⇒ Object



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

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

#get_servers_count(options = {}) ⇒ Object



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

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

#push_templates(attributes = {}) ⇒ Object



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

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



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

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



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

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



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

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

#rotate_domain_dkim(id) ⇒ Object



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

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

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



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

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

#servers(options = {}) ⇒ Object



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

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

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



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

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



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

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



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

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)


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

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)


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

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

#verify_domain_dkim(id) ⇒ Object



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

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

#verify_domain_return_path(id) ⇒ Object



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

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