Skip to content

Commit 91f1650

Browse files
committed
adding endpoint examples and sample usecases
1 parent 059d112 commit 91f1650

File tree

2 files changed

+1397
-0
lines changed

2 files changed

+1397
-0
lines changed

example-endpoints.md

+333
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,333 @@
1+
## Table of Content
2+
* [fetch event logs](#example1)
3+
* [fetch summary stats](#example2)
4+
* [Domain Add](#example3)
5+
* [Domain delete](#example4)
6+
* [Suppression add](#example5)
7+
* [Suppression delete](#example6)
8+
* [create subaccount](#example7)
9+
* [update subaccount](#example8)
10+
* [enable/disable subaccount](#example9)
11+
* [delete subaccount](#example10)
12+
* [set recurring credit in subaccount](#example11)
13+
* [add credit in subaccount](#example12)
14+
* [get credit details of subaccount](#example13)
15+
16+
<a name="example1"></a>
17+
## fetch event logs
18+
19+
```ruby
20+
require 'pepipost'
21+
22+
include Pepipost
23+
24+
api_key = 'your api_key here'
25+
26+
client = PepipostClient.new(api_key: api_key)
27+
28+
events_controller = client.events
29+
startdate = Date.iso8601('2016-03-13')
30+
events = EventsEnum::SENT
31+
sort = SortEnum::ASC
32+
enddate = Date.iso8601('2020-05-26')
33+
subject = 'test'
34+
35+
36+
begin
37+
result = events_controller.get_events_get(startdate, events, sort, enddate, nil, nil, subject, nil, nil, email)
38+
rescue APIException => ex
39+
puts "Caught APIException: #{ex.message}"
40+
end
41+
```
42+
43+
<a name="example2"></a>
44+
## fetch summary stats
45+
46+
```ruby
47+
require 'pepipost'
48+
49+
include Pepipost
50+
51+
api_key = 'your api_key here'
52+
53+
client = PepipostClient.new(api_key: api_key)
54+
55+
stats_controller = client.stats
56+
startdate = Date.iso8601('2016-03-13')
57+
enddate = Date.iso8601('2020-05-26')
58+
aggregated_by = AggregatedByEnum::WEEK
59+
offset = 100
60+
limit = 1
61+
62+
begin
63+
result = stats_controller.get_stats_get(startdate, enddate, aggregated_by, offset, limit)
64+
rescue APIException => ex
65+
puts "Caught APIException: #{ex.message}"
66+
end
67+
```
68+
<a name="example3"></a>
69+
## Domain Add
70+
71+
```ruby
72+
require 'pepipost'
73+
74+
include Pepipost
75+
76+
api_key = 'your api_key here'
77+
78+
client = PepipostClient.new(api_key: api_key)
79+
80+
domain_controller = client.domain
81+
body = DomainStruct.new
82+
body.domain = 'example.com'
83+
body.envelope_name = 'test'
84+
85+
begin
86+
result = domain_controller.add_domain(body)
87+
rescue APIException => ex
88+
puts "Caught APIException: #{ex.message}"
89+
end
90+
```
91+
92+
<a name="example4"></a>
93+
## Domain delete
94+
95+
```ruby
96+
require 'pepipost'
97+
98+
include Pepipost
99+
100+
api_key = 'your api_key here'
101+
102+
client = PepipostClient.new(api_key: api_key)
103+
104+
domain_delete_controller = client.domain_delete
105+
body = DeleteDomain.new
106+
body.domain = 'example.com'
107+
108+
begin
109+
result = domain_delete_controller.delete_domain(body)
110+
rescue APIException => ex
111+
puts "Caught APIException: #{ex.message}"
112+
end
113+
```
114+
115+
<a name="example5"></a>
116+
## Suppression add
117+
118+
```ruby
119+
require 'pepipost'
120+
121+
include Pepipost
122+
123+
api_key = 'your api_key here'
124+
125+
client = PepipostClient.new(api_key: api_key)
126+
127+
suppression_controller = client.suppression
128+
body = AddEmailOrDomainToSuppressionList.new
129+
body.domain = 'example.com'
130+
body.email = '[email protected]'
131+
132+
begin
133+
result = suppression_controller.add_domain_or_email_to_suppression_list(body)
134+
rescue APIException => ex
135+
puts "Caught APIException: #{ex.message}"
136+
end
137+
```
138+
139+
<a name="example6"></a>
140+
## Suppression delete
141+
142+
```ruby
143+
require 'pepipost'
144+
145+
include Pepipost
146+
147+
api_key = 'your api_key here'
148+
149+
client = PepipostClient.new(api_key: api_key)
150+
151+
suppression_controller = client.suppression
152+
body = RemoveEmailOrDomainToSuppressionList.new
153+
body.domain = 'example.com'
154+
body.email = '[email protected]'
155+
156+
begin
157+
result = suppression_controller.remove_domain_or_email_to_suppression_list(body)
158+
rescue APIException => ex
159+
puts "Caught APIException: #{ex.message}"
160+
end
161+
```
162+
163+
<a name="example7"></a>
164+
## create subaccount
165+
166+
```ruby
167+
require 'pepipost'
168+
169+
include Pepipost
170+
171+
api_key = 'your api_key here'
172+
173+
client = PepipostClient.new(api_key: api_key)
174+
175+
subaccounts_create_subaccount_controller = client.subaccounts_create_subaccount
176+
body = CreateSubaccount.new
177+
body.username = 'name'
178+
body.email = 'email1.gmail.com'
179+
body.setpassword = '0'
180+
body.password = 'pwd'
181+
182+
begin
183+
result = subaccounts_create_subaccount_controller.create_subaccounts_create_subaccount_post(body)
184+
rescue APIException => ex
185+
puts "Caught APIException: #{ex.message}"
186+
end
187+
```
188+
189+
<a name="example8"></a>
190+
## update subaccount
191+
192+
```ruby
193+
require 'pepipost'
194+
195+
include Pepipost
196+
197+
api_key = 'your api_key here'
198+
199+
client = PepipostClient.new(api_key: api_key)
200+
201+
subaccounts_update_subaccount_controller = client.subaccounts_update_subaccount
202+
body = UpdateSubaccount.new
203+
body.username = 'username'
204+
body.new_email = '[email protected]'
205+
body.new_password = 'pwd'
206+
body.confirm_password = 'pwd'
207+
208+
begin
209+
result = subaccounts_update_subaccount_controller.create_subaccounts_update_subaccount_post(body)
210+
rescue APIException => ex
211+
puts "Caught APIException: #{ex.message}"
212+
end
213+
```
214+
215+
<a name="example9"></a>
216+
## enable/disable subaccount
217+
218+
```ruby
219+
require 'pepipost'
220+
221+
include Pepipost
222+
223+
api_key = 'your api_key here'
224+
225+
client = PepipostClient.new(api_key: api_key)
226+
227+
subaccounts_controller = client.subaccounts
228+
body = EnableOrDisableSubacoount.new
229+
body.username = 'username'
230+
body.disabled = true
231+
232+
begin
233+
result = subaccounts_controller.update_subaccounts_patch(body)
234+
rescue APIException => ex
235+
puts "Caught APIException: #{ex.message}"
236+
end
237+
```
238+
239+
<a name="example10"></a>
240+
## delete subaccount
241+
242+
```ruby
243+
require 'pepipost'
244+
245+
include Pepipost
246+
247+
api_key = 'your api_key here'
248+
249+
client = PepipostClient.new(api_key: api_key)
250+
251+
subaccounts_delete_controller = client.subaccounts_delete
252+
body = DeleteSubacoount.new
253+
body.username = 'username'
254+
255+
begin
256+
result = subaccounts_delete_controller.delete_subaccounts_delete_delete(body)
257+
rescue APIException => ex
258+
puts "Caught APIException: #{ex.message}"
259+
end
260+
```
261+
262+
<a name="example11"></a>
263+
## set recurring credit in subaccount
264+
265+
```ruby
266+
require 'pepipost'
267+
268+
include Pepipost
269+
270+
api_key = 'your api_key here'
271+
272+
client = PepipostClient.new(api_key: api_key)
273+
274+
setrecurringcreditddetails_controller = client.setrecurringcreditddetails
275+
body = UpdateRecurringCredisOfSubaccount.new
276+
body.username = 'username'
277+
body.recurring_credit = 10
278+
body.timeperiod = TimeperiodEnum::MONHTLY
279+
280+
begin
281+
result = setrecurringcreditddetails_controller.create_setrecurringcreditddetails_post(body)
282+
rescue APIException => ex
283+
puts "Caught APIException: #{ex.message}"
284+
end
285+
```
286+
287+
<a name="example12"></a>
288+
## add credit in subaccount
289+
290+
```ruby
291+
require 'pepipost'
292+
293+
include Pepipost
294+
295+
api_key = 'your api_key here'
296+
297+
client = PepipostClient.new(api_key: api_key)
298+
299+
subaccounts_setsubaccountcredit_controller = client.subaccounts_setsubaccountcredit
300+
body = UpdateCredisOfSubaccount.new
301+
body.username = 'username'
302+
body.action = ActionEnum::DECREASE
303+
body.amount = 100
304+
305+
begin
306+
result = subaccounts_setsubaccountcredit_controller.create_subaccounts_setsubaccountcredit_post(body)
307+
rescue APIException => ex
308+
puts "Caught APIException: #{ex.message}"
309+
end
310+
```
311+
312+
<a name="example13"></a>
313+
## get credit details of subaccount
314+
315+
```ruby
316+
require 'pepipost'
317+
318+
include Pepipost
319+
320+
api_key = 'your api_key here'
321+
322+
client = PepipostClient.new(api_key: api_key)
323+
324+
subaccounts_get_sub_accounts_controller = client.subaccounts_get_sub_accounts
325+
limit = '100'
326+
offset = '0'
327+
328+
begin
329+
result = subaccounts_get_sub_accounts_controller.get_subaccounts_get_sub_accounts_get(limit, offset)
330+
rescue APIException => ex
331+
puts "Caught APIException: #{ex.message}"
332+
end
333+
```

0 commit comments

Comments
 (0)