package ez_api

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file ezSendgrid_services.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
(**************************************************************************)
(*                                                                        *)
(*                 Copyright 2018-2023 OCamlPro                           *)
(*                                                                        *)
(*  All rights reserved. This file is distributed under the terms of the  *)
(*  GNU Lesser General Public License version 2.1, with the special       *)
(*  exception on linking described in the file LICENSE.                   *)
(*                                                                        *)
(**************************************************************************)

open EzSendgrid_types
open EzSendgrid_encoding
open EzAPI

let sendgrid_section = Doc.section "Sendgrid Requests"
let sendgrid_host = BASE "https://api.sendgrid.com/v3"

let arg_id = Arg.string ~example:"base64_hash" "id"

let ids_param = Param.string ~descr:"Sendgrid contact ids" ~name:"ids" "ids"
let contact_ids_param = Param.string ~descr:"Sendgrid contact ids" ~name:"contact_ids" "contact_ids"
let delete_all_param = Param.bool ~descr:"Sendgrid delete all contacts" ~name:"delete_all_contacts" "delete_all_contacts"

let send encoding : ('a mail, unit, string option, Security.bearer) post_service0 =
  post_service
    ~section:sendgrid_section
    ~name:"sendgrid_send"
    ~input:(mail encoding)
    ~output:Json_encoding.empty
    EzAPI.Path.(root // "mail" // "send")

let add_contacts : (string list option * contact list, string, string option, EzAPI.Security.bearer) EzAPI.post_service0 =
  EzAPI.post_service
    ~register:false
    ~section:sendgrid_section
    ~name:"sendgrid_add_contacts"
    ~input:add_contacts_enc
    ~output:job_output
    ~meth:`PUT
    EzAPI.Path.(root // "marketing" // "contacts")

let delete_contacts : (unit, string, string option, Security.bearer) EzAPI.post_service0 =
  EzAPI.raw_service
    ~register:false
    ~section:sendgrid_section
    ~name:"sendgrid_delete_contacts"
    ~input:Empty
    ~output:(Json job_output)
    ~meth:`DELETE
    ~params:[ids_param; delete_all_param]
    EzAPI.Path.(root // "marketing" // "contacts")

let contacts_count : (int, string option, Security.bearer) EzAPI.service0 =
  EzAPI.service
    ~register:false
    ~section:sendgrid_section
    ~name:"sendgrid_contacts_count"
    ~output:contacts_count
    EzAPI.Path.(root // "marketing" // "contacts" // "count")

let get_contact : (string, contact * contact_more, string option, Security.bearer) EzAPI.service1 =
  EzAPI.service
    ~register:false
    ~section:sendgrid_section
    ~name:"sendgrid_get_contact"
    ~output:get_contact
    EzAPI.Path.(root // "marketing" // "contacts" /: arg_id)

let search_contacts : (string, int * (contact * contact_more) list, string option, Security.bearer) EzAPI.post_service0 =
  EzAPI.post_service
    ~register:false
    ~section:sendgrid_section
    ~name:"sendgrid_search_contacts"
    ~input:query
    ~output:(search_output EzSendgrid_encoding.get_contact)
    EzAPI.Path.(root // "marketing" // "contacts" // "search")

let remove_contact_list : (string, string, string option, Security.bearer) EzAPI.service1 =
  EzAPI.service
    ~register:false
    ~section:sendgrid_section
    ~name:"sendgrid_remove_contact_list"
    ~output:job_output
    ~meth:`DELETE
    ~params:[contact_ids_param]
    EzAPI.Path.(root // "marketing" // "lists" /: arg_id // "contacts")
OCaml

Innovation. Community. Security.