Skip to content

Commit

Permalink
Change response to include message, add public json
Browse files Browse the repository at this point in the history
  • Loading branch information
BDQ committed May 28, 2013
1 parent 1de109c commit b4a8d6f
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: [email protected]:spree/endpoint_base.git
revision: c40b9b729247298fc7e91bc4f1f8659388db1d7c
revision: 885403ef1a336cf152e056f9a1803bde9d4c2167
specs:
endpoint_base (2.0)
active_support
Expand All @@ -15,7 +15,7 @@ GEM
activesupport (= 3.0.0)
activesupport (3.0.0)
addressable (2.3.4)
backports (3.3.0)
backports (3.3.1)
capistrano (2.15.4)
highline
net-scp (>= 1.0.0)
Expand Down
8 changes: 2 additions & 6 deletions lib/mandrill_sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ def consume
if %w{sent queued}.include?(response['status'])
return 200, { 'message_id' => message_id,
'order_number' => order['number'],
'result' => :success,
'code' => 200,
'mandrill_response' => response
'messages' => [{ 'message' => 'email:sent', 'payload' => response }]
}
else
return 500, { 'message_id' => message_id,
'order_number' => order['number'],
'result' => :failure,
'code' => 400,
'mandrill_response' => response
'messages' => [{ 'message' => 'email:failure', 'payload' => response }]
}
end

Expand Down
13 changes: 13 additions & 0 deletions public/email.failure.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "object",
"properties": {
"status": {
"type": "string",
"required": true
},
"email": {
"type": "string",
"required": true
}
}
}
13 changes: 13 additions & 0 deletions public/email.sent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "object",
"properties": {
"status": {
"type": "string",
"required": true
},
"email": {
"type": "string",
"required": true
}
}
}
95 changes: 95 additions & 0 deletions public/endpoint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"name": "mandrill",
"description": "Sends transactional emails using Mandrill",
"consumers": [
{
"name": "order_confirmation",
"path": "/order_confirmation",
"requires": {
"parameters": [
{"name": "api_key", "description": "Mandril API key" },
{"name": "order_confirmation.from", "description": "Reply-to address for email" },
{"name": "order_confirmation.subject", "description": "Subject of email" },
{"name": "order_confirmation.template", "description": "Mandrill template name" }
]
},
"recommends": {
"keys": ["order:new", "order:update"],
"events": [
{
"keys": [ {"name": "order_number", "path": "payload.order.actual.number" } ],
"details": [ {"name": "email", "path": "payload.order.actual.email" } ]
}
],
"filters": [{"path": "payload.actual.order.complete", "operator": "eq", "value": "complete"}],
"options": {
"allow_retries": true
}
},
"produces": {
"messages": [
{"message": "email:sent", "schema": "http://mandrill.spree.mx/email.sent.json"},
{"message": "email:failure", "schema": "http://mandrill.spree.mx/email.failure.json" }
]
}
},{
"name": "order_cancellation",
"path": "/order_cancellation",
"requires": {
"parameters": [
{"name": "api_key", "description": "Mandril API key" },
{"name": "order_cancellation.from", "description": "Reply-to address for email" },
{"name": "order_cancellation.subject", "description": "Subject of email" },
{"name": "order_cancellation.template", "description": "Mandrill template name" }
]
},
"recommends": {
"keys": ["order:canceled"],
"events": [
{
"keys": [ {"name": "order_number", "path": "payload.order.actual.number" } ],
"details": [ {"name": "email", "path": "payload.order.actual.email" } ]
}
],
"options": {
"allow_retries": true
}
},
"produces": {
"messages": [
{"message": "email:sent", "schema": "http://mandrill.spree.mx/email.sent.json"},
{"message": "email:failure", "schema": "http://mandrill.spree.mx/email.failure.json" }
]
}
},{
"name": "shipment_confirmation",
"path": "/shipment_confirmation",
"requires": {
"parameters": [
{"name": "api_key", "description": "Mandril API key" },
{"name": "shipment_confirmation.from", "description": "Reply-to address for email" },
{"name": "shipment_confirmation.subject", "description": "Subject of email" },
{"name": "shipment_confirmation.template", "description": "Mandrill template name" }
]
},
"recommends": {
"keys": ["shipment:confirmation"],
"events": [
{
"keys": [ {"name": "order_number", "path": "payload.order.actual.number" } ],
"details": [ {"name": "email", "path": "payload.order.actual.email" } ]
}
],
"options": {
"allow_retries": true
}
},
"produces": {
"messages": [
{"message": "email:sent", "schema": "http://mandrill.spree.mx/email.sent.json"},
{"message": "email:failure", "schema": "http://mandrill.spree.mx/email.failure.json" }
]
}
}
]
}

0 comments on commit b4a8d6f

Please sign in to comment.