Class: Svix::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/svix/api/endpoint.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Endpoint

Returns a new instance of Endpoint.



8
9
10
# File 'lib/svix/api/endpoint.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#create(app_id, endpoint_in, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/svix/api/endpoint.rb', line 26

def create(app_id, endpoint_in, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/api/v1/app/#{app_id}/endpoint",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: endpoint_in
  )
  EndpointOut.deserialize(res)
end

#delete(app_id, endpoint_id) ⇒ Object



56
57
58
59
60
61
# File 'lib/svix/api/endpoint.rb', line 56

def delete(app_id, endpoint_id)
  @client.execute_request(
    "DELETE",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}"
  )
end

#get(app_id, endpoint_id) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/svix/api/endpoint.rb', line 39

def get(app_id, endpoint_id)
  res = @client.execute_request(
    "GET",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}"
  )
  EndpointOut.deserialize(res)
end

#get_headers(app_id, endpoint_id) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/svix/api/endpoint.rb', line 72

def get_headers(app_id, endpoint_id)
  res = @client.execute_request(
    "GET",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/headers"
  )
  EndpointHeadersOut.deserialize(res)
end

#get_secret(app_id, endpoint_id) ⇒ Object



122
123
124
125
126
127
128
# File 'lib/svix/api/endpoint.rb', line 122

def get_secret(app_id, endpoint_id)
  res = @client.execute_request(
    "GET",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/secret"
  )
  EndpointSecretOut.deserialize(res)
end

#get_stats(app_id, endpoint_id, options = {}) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/svix/api/endpoint.rb', line 155

def get_stats(app_id, endpoint_id, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "GET",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/stats",
    query_params: {
      "since" => options["since"],
      "until" => options["until"]
    }
  )
  EndpointStats.deserialize(res)
end

#list(app_id, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/svix/api/endpoint.rb', line 12

def list(app_id, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "GET",
    "/api/v1/app/#{app_id}/endpoint",
    query_params: {
      "limit" => options["limit"],
      "iterator" => options["iterator"],
      "order" => options["order"]
    }
  )
  ListResponseEndpointOut.deserialize(res)
end

#patch(app_id, endpoint_id, endpoint_patch) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/svix/api/endpoint.rb', line 63

def patch(app_id, endpoint_id, endpoint_patch)
  res = @client.execute_request(
    "PATCH",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}",
    body: endpoint_patch
  )
  EndpointOut.deserialize(res)
end

#patch_headers(app_id, endpoint_id, endpoint_headers_patch_in) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/svix/api/endpoint.rb', line 88

def patch_headers(app_id, endpoint_id, endpoint_headers_patch_in)
  @client.execute_request(
    "PATCH",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/headers",
    body: endpoint_headers_patch_in
  )
end

#patch_transformation(app_id, endpoint_id, endpoint_transformation_patch) ⇒ Object



176
177
178
179
180
181
182
# File 'lib/svix/api/endpoint.rb', line 176

def patch_transformation(app_id, endpoint_id, endpoint_transformation_patch)
  @client.execute_request(
    "PATCH",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/transformation",
    body: endpoint_transformation_patch
  )
end

#recover(app_id, endpoint_id, recover_in, options = {}) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/svix/api/endpoint.rb', line 96

def recover(app_id, endpoint_id, recover_in, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/recover",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: recover_in
  )
  RecoverOut.deserialize(res)
end

#replay_missing(app_id, endpoint_id, replay_in, options = {}) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/svix/api/endpoint.rb', line 109

def replay_missing(app_id, endpoint_id, replay_in, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/replay-missing",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: replay_in
  )
  ReplayOut.deserialize(res)
end

#rotate_secret(app_id, endpoint_id, endpoint_secret_rotate_in, options = {}) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/svix/api/endpoint.rb', line 130

def rotate_secret(app_id, endpoint_id, endpoint_secret_rotate_in, options = {})
  options = options.transform_keys(&:to_s)
  @client.execute_request(
    "POST",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/secret/rotate",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: endpoint_secret_rotate_in
  )
end

#send_example(app_id, endpoint_id, event_example_in, options = {}) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/svix/api/endpoint.rb', line 142

def send_example(app_id, endpoint_id, event_example_in, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/send-example",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: event_example_in
  )
  MessageOut.deserialize(res)
end

#transformation_get(app_id, endpoint_id) ⇒ Object



168
169
170
171
172
173
174
# File 'lib/svix/api/endpoint.rb', line 168

def transformation_get(app_id, endpoint_id)
  res = @client.execute_request(
    "GET",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/transformation"
  )
  EndpointTransformationOut.deserialize(res)
end

#transformation_partial_update(app_id, endpoint_id, endpoint_transformation_in) ⇒ Object



184
185
186
187
188
189
190
# File 'lib/svix/api/endpoint.rb', line 184

def transformation_partial_update(app_id, endpoint_id, endpoint_transformation_in)
  @client.execute_request(
    "PATCH",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/transformation",
    body: endpoint_transformation_in
  )
end

#update(app_id, endpoint_id, endpoint_update) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/svix/api/endpoint.rb', line 47

def update(app_id, endpoint_id, endpoint_update)
  res = @client.execute_request(
    "PUT",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}",
    body: endpoint_update
  )
  EndpointOut.deserialize(res)
end

#update_headers(app_id, endpoint_id, endpoint_headers_in) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/svix/api/endpoint.rb', line 80

def update_headers(app_id, endpoint_id, endpoint_headers_in)
  @client.execute_request(
    "PUT",
    "/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/headers",
    body: endpoint_headers_in
  )
end