Skip to content

Commit

Permalink
chore: use symbol keys in send resource
Browse files Browse the repository at this point in the history
  • Loading branch information
wout committed Apr 30, 2024
1 parent 64a688e commit f1989f0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
30 changes: 15 additions & 15 deletions spec/mailjet/resources/send_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ end

private def valid_send_message_payload_v3_1
{
"From": {
"Email": "from@email.com",
"Name": "Me",
From: {
Email: "from@email.com",
Name: "Me",
},
"To": [
To: [
{
"Email": "to@email.com",
"Name": "You",
Email: "to@email.com",
Name: "You",
},
],
"Subject": "My first Mailjet Email!",
"TextPart": "Greetings from Mailjet!",
"HTMLPart": <<-HTML
Subject: "My first Mailjet Email!",
TextPart: "Greetings from Mailjet!",
HTMLPart: <<-HTML
<h3>Dear passenger 1, welcome to
<a href='https://www.mailjet.com/'>Mailjet</a>!
</h3><br />May the delivery force be with you!
Expand All @@ -121,15 +121,15 @@ end

private def valid_send_message_payload_v3
{
"FromEmail": "pilot@mailjet.com",
"FromName": "Your Mailjet Pilot",
"Recipients": [
FromEmail: "pilot@mailjet.com",
FromName: "Your Mailjet Pilot",
Recipients: [
{
"Email": "passenger@mailjet.com",
"Name": "Passenger 1",
Email: "passenger@mailjet.com",
Name: "Passenger 1",
},
],
"Subject": "Your email flight plan!",
Subject: "Your email flight plan!",
"Text-part": "Dear passenger, welcome to Mailjet!",
"Html-part": <<-HTML
<h3>Dear passenger, welcome to Mailjet!</h3>
Expand Down
44 changes: 22 additions & 22 deletions src/mailjet/resources/send.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,52 +26,52 @@ struct Mailjet
include Json::Fields

json_fields({
"Bcc": Array(DeliveryReceipt)?,
"Cc": Array(DeliveryReceipt)?,
"CustomID": String?,
"Errors": Array(DeliveryError)?,
"Status": String,
"To": Array(DeliveryReceipt)?,
Bcc: Array(DeliveryReceipt)?,
Cc: Array(DeliveryReceipt)?,
CustomID: String?,
Errors: Array(DeliveryError)?,
Status: String,
To: Array(DeliveryReceipt)?,
})
end

struct SentMessage
include Json::Fields

json_fields({
"Email": String,
"MessageID": Int64,
"MessageUUID": String,
Email: String,
MessageID: Int64,
MessageUUID: String,
})
end

struct DeliveryReceipt
include Json::Fields

json_fields({
"Email": String,
"MessageHref": String,
"MessageID": Int64,
"MessageUUID": String,
Email: String,
MessageHref: String,
MessageID: Int64,
MessageUUID: String,
})
end

struct DeliveryError
include Json::Fields

json_fields({
"ErrorCode": String,
"ErrorIdentifier": String,
"ErrorMessage": String,
"ErrorRelatedTo": Array(String),
"StatusCode": Int32,
ErrorCode: String,
ErrorIdentifier: String,
ErrorMessage: String,
ErrorRelatedTo: Array(String),
StatusCode: Int32,
})
end
end

struct SendV3 < Send
# :nodoc:
can_create("send", {"Sent": Array(SentMessage)})
can_create("send", {Sent: Array(SentMessage)})

# Deliver an array of messages
#
Expand All @@ -88,7 +88,7 @@ struct Mailjet
client : Client = Client.new
)
create(
{"Messages": messages},
{Messages: messages},
params: {version: "v3"},
client: client
).sent
Expand All @@ -97,7 +97,7 @@ struct Mailjet

struct SendV3_1 < Send
# :nodoc:
can_create("send", {"Messages": Array(ResponseMessage)})
can_create("send", {Messages: Array(ResponseMessage)})

# Deliver an array of messages
#
Expand All @@ -114,7 +114,7 @@ struct Mailjet
client : Client = Client.new
)
create(
{"Messages": messages},
{Messages: messages},
params: {version: "v3.1"},
client: client
).messages
Expand Down

0 comments on commit f1989f0

Please sign in to comment.