Skip to content

Commit a1755b6

Browse files
adding metadata and tags to examples
1 parent 30bdcb8 commit a1755b6

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

python-examples/basic/basic_send_complex.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from socketlabs.injectionapi import SocketLabsClient
55
from socketlabs.injectionapi.message.__imports__ import \
6-
Attachment, BasicMessage, CustomHeader, EmailAddress
6+
Attachment, BasicMessage, CustomHeader, EmailAddress, Metadata
77

88

99
# build the message
@@ -132,6 +132,36 @@
132132
# Add CustomHeader using the add_custom_header function
133133
message.add_custom_header("testMessageHeader", "I am a message header")
134134

135+
# Adding Metadata
136+
# ==========================
137+
# Add Metadata using a list
138+
139+
metadata = [
140+
Metadata("example-type", "basic-send-complex-example"),
141+
Metadata("message-contains", "attachments, headers")
142+
]
143+
message.metadata = metadata
144+
145+
# Add Metadata directly to the list
146+
message.metadata.append(Metadata("message-has-attachments", "true"))
147+
148+
# Add Metadata using the add_metadata function
149+
message.add_metadata("testMessageHeader", "I am metadata")
150+
151+
# Adding Tags
152+
# ==========================
153+
# Add Metadata using a list
154+
155+
tags = [
156+
"example-type:basic-send-complex-example"
157+
]
158+
message.tags = metadata
159+
160+
# Add Metadata directly to the list
161+
message.metadata.append("message-has-attachments:true")
162+
163+
# Add Metadata using the add_metadata function
164+
message.add_tags("I am a test message")
135165

136166
# get credentials from environment variables
137167
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))

python-examples/bulk/bulk_send_complex.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@
156156

157157
message.add_attachment(attachment4)
158158

159-
160159
# Adding Custom Headers
161160
# ==========================
162161
# Add CustomHeader using a list
@@ -172,6 +171,36 @@
172171
# Add CustomHeader using the add_custom_header function
173172
message.add_custom_header("testMessageHeader", "I am a message header")
174173

174+
# Adding Metadata
175+
# ==========================
176+
# Add Metadata using a list
177+
178+
metadata = [
179+
Metadata("example-type", "basic-send-complex-example"),
180+
Metadata("message-contains", "attachments, headers")
181+
]
182+
message.metadata = metadata
183+
184+
# Add Metadata directly to the list
185+
message.metadata.append(Metadata("message-has-attachments", "true"))
186+
187+
# Add Metadata using the add_metadata function
188+
message.add_metadata("testMessageHeader", "I am metadata")
189+
190+
# Adding Tags
191+
# ==========================
192+
# Add Metadata using a list
193+
194+
tags = [
195+
"example-type:basic-send-complex-example"
196+
]
197+
message.tags = metadata
198+
199+
# Add Metadata directly to the list
200+
message.metadata.append("message-has-attachments:true")
201+
202+
# Add Metadata using the add_metadata function
203+
message.add_tags("I am a test message")
175204

176205
# get credentials from environment variables
177206
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))

0 commit comments

Comments
 (0)