Skip to content

Latest commit

 

History

History
333 lines (243 loc) · 6.91 KB

example-endpoints.md

File metadata and controls

333 lines (243 loc) · 6.91 KB

Table of Content

fetch event logs

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

events_controller = client.events
startdate = Date.iso8601('2016-03-13')
events = EventsEnum::SENT
sort = SortEnum::ASC
enddate = Date.iso8601('2020-05-26')
subject = 'test'
email = '[email protected]'

begin
  result = events_controller.get_events_get(startdate, events, sort, enddate, nil, nil, subject, nil, nil, email)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

fetch summary stats

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

stats_controller = client.stats
startdate = Date.iso8601('2016-03-13')
enddate = Date.iso8601('2020-05-26')
aggregated_by = AggregatedByEnum::WEEK
offset = 100
limit = 1

begin
  result = stats_controller.get_stats_get(startdate, enddate, aggregated_by, offset, limit)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

Domain Add

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

domain_controller = client.domain
body = DomainStruct.new
body.domain = 'example.com'
body.envelope_name = 'test'

begin
  result = domain_controller.add_domain(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

Domain delete

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

domain_delete_controller = client.domain_delete
body = DeleteDomain.new
body.domain = 'example.com'

begin
  result = domain_delete_controller.delete_domain(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

Suppression add

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

suppression_controller = client.suppression
body = AddEmailOrDomainToSuppressionList.new
body.domain = 'example.com'
body.email = '[email protected]'

begin
  result = suppression_controller.add_domain_or_email_to_suppression_list(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

Suppression delete

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

suppression_controller = client.suppression
body = RemoveEmailOrDomainToSuppressionList.new
body.domain = 'example.com'
body.email = '[email protected]'

begin
  result = suppression_controller.remove_domain_or_email_to_suppression_list(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

create subaccount

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

subaccounts_create_subaccount_controller = client.subaccounts_create_subaccount
body = CreateSubaccount.new
body.username = 'name'
body.email = 'email1.gmail.com'
body.setpassword = '0'
body.password = 'pwd'

begin
  result = subaccounts_create_subaccount_controller.create_subaccounts_create_subaccount_post(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

update subaccount

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

subaccounts_update_subaccount_controller = client.subaccounts_update_subaccount
body = UpdateSubaccount.new
body.username = 'username'
body.new_email = '[email protected]'
body.new_password = 'pwd'
body.confirm_password = 'pwd'

begin
  result = subaccounts_update_subaccount_controller.create_subaccounts_update_subaccount_post(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

enable/disable subaccount

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

subaccounts_controller = client.subaccounts
body = EnableOrDisableSubacoount.new
body.username = 'username'
body.disabled = true

begin
  result = subaccounts_controller.update_subaccounts_patch(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

delete subaccount

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

subaccounts_delete_controller = client.subaccounts_delete
body = DeleteSubacoount.new
body.username = 'username'

begin
  result = subaccounts_delete_controller.delete_subaccounts_delete_delete(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

set recurring credit in subaccount

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

setrecurringcreditddetails_controller = client.setrecurringcreditddetails
body = UpdateRecurringCredisOfSubaccount.new
body.username = 'username'
body.recurring_credit = 10
body.timeperiod = TimeperiodEnum::MONHTLY

begin
  result = setrecurringcreditddetails_controller.create_setrecurringcreditddetails_post(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

add credit in subaccount

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

subaccounts_setsubaccountcredit_controller = client.subaccounts_setsubaccountcredit
body = UpdateCredisOfSubaccount.new
body.username = 'username'
body.action = ActionEnum::DECREASE
body.amount = 100

begin
  result = subaccounts_setsubaccountcredit_controller.create_subaccounts_setsubaccountcredit_post(body)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end

get credit details of subaccount

require 'pepipost'

include Pepipost

api_key = 'your api_key here'

client = PepipostClient.new(api_key: api_key)

subaccounts_get_sub_accounts_controller = client.subaccounts_get_sub_accounts
limit = '100'
offset = '0'

begin
  result = subaccounts_get_sub_accounts_controller.get_subaccounts_get_sub_accounts_get(limit, offset)
rescue APIException => ex
  puts "Caught APIException: #{ex.message}"
end