Skip to content

Commit

Permalink
Add support for WA Cloud API
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Apr 8, 2022
1 parent 1eed670 commit e223a2e
Show file tree
Hide file tree
Showing 16 changed files with 1,684 additions and 20 deletions.
781 changes: 764 additions & 17 deletions handlers/facebookapp/facebookapp.go

Large diffs are not rendered by default.

310 changes: 307 additions & 3 deletions handlers/facebookapp/facebookapp_test.go

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions handlers/facebookapp/testdata/cwa/audioCWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "8856996819413533",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "12345",
"phone_number_id": "27681414235104944"
},
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "5678"
}
],
"messages": [
{
"from": "5678",
"id": "external_id",
"audio": {
"file": "/usr/local/wamedia/shared/b1cf38-8734-4ad3-b4a1-ef0c10d0d683",
"id": "id_audio",
"mime_type": "image/jpeg",
"sha256": "29ed500fa64eb55fc19dc4124acb300e5dcc54a0f822a301ae99944db",
"caption": "Check out my new phone!"
},
"timestamp": "1454119029",
"type": "audio"
}
]
},
"field": "messages"
}
]
}
]
}
44 changes: 44 additions & 0 deletions handlers/facebookapp/testdata/cwa/buttonCWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "8856996819413533",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "12345",
"phone_number_id": "27681414235104944"
},
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "5678"
}
],
"messages": [
{
"button": {
"payload": "No-Button-Payload",
"text": "No"
},
"context": {
"from": "5678",
"id": "gBGGFmkiWVVPAgkgQkwi7IORac0"
},
"from": "5678",
"id": "external_id",
"timestamp": "1454119029",
"type": "button"
}
]
},
"field": "messages"
}
]
}
]
}
43 changes: 43 additions & 0 deletions handlers/facebookapp/testdata/cwa/documentCWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "8856996819413533",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "12345",
"phone_number_id": "27681414235104944"
},
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "5678"
}
],
"messages": [
{
"from": "5678",
"id": "external_id",
"timestamp": "1454119029",
"type": "document",
"document": {
"caption": "80skaraokesonglistartist",
"file": "/usr/local/wamedia/shared/fc233119-733f-49c-bcbd-b2f68f798e33",
"id": "id_document",
"mime_type": "application/pdf",
"sha256": "3b11fa6ef2bde1dd14726e09d3edaf782120919d06f6484f32d5d5caa4b8e"
}
}
]
},
"field": "messages"
}
]
}
]
}
48 changes: 48 additions & 0 deletions handlers/facebookapp/testdata/cwa/duplicateCWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "8856996819413533",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "12345",
"phone_number_id": "27681414235104944"
},
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "5678"
}
],
"messages": [
{
"from": "5678",
"id": "external_id",
"timestamp": "1454119029",
"text": {
"body": "Hello World"
},
"type": "text"
},
{
"from": "5678",
"id": "external_id",
"timestamp": "1454119029",
"text": {
"body": "Hello World"
},
"type": "text"
}
]
},
"field": "messages"
}
]
}
]
}
39 changes: 39 additions & 0 deletions handlers/facebookapp/testdata/cwa/helloCWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "8856996819413533",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "12345",
"phone_number_id": "27681414235104944"
},
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "5678"
}
],
"messages": [
{
"from": "5678",
"id": "external_id",
"timestamp": "1454119029",
"text": {
"body": "Hello World"
},
"type": "text"
}
]
},
"field": "messages"
}
]
}
]
}
49 changes: 49 additions & 0 deletions handlers/facebookapp/testdata/cwa/ignoreStatusCWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "8856996819413533",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "12345",
"phone_number_id": "27681414235104944"
},
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "5678"
}
],
"statuses": [
{
"id": "external_id",
"recipient_id": "5678",
"status": "deleted",
"timestamp": "1454119029",
"type": "message",
"conversation": {
"id": "CONVERSATION_ID",
"expiration_timestamp": 1454119029,
"origin": {
"type": "referral_conversion"
}
},
"pricing": {
"pricing_model": "CBP",
"billable": false,
"category": "referral_conversion"
}
}
]
},
"field": "messages"
}
]
}
]
}
43 changes: 43 additions & 0 deletions handlers/facebookapp/testdata/cwa/imageCWA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "8856996819413533",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "12345",
"phone_number_id": "27681414235104944"
},
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "5678"
}
],
"messages": [
{
"from": "5678",
"id": "external_id",
"image": {
"file": "/usr/local/wamedia/shared/b1cf38-8734-4ad3-b4a1-ef0c10d0d683",
"id": "id_image",
"mime_type": "image/jpeg",
"sha256": "29ed500fa64eb55fc19dc4124acb300e5dcc54a0f822a301ae99944db",
"caption": "Check out my new phone!"
},
"timestamp": "1454119029",
"type": "image"
}
]
},
"field": "messages"
}
]
}
]
}
39 changes: 39 additions & 0 deletions handlers/facebookapp/testdata/cwa/invalidFrom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "8856996819413533",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "12345",
"phone_number_id": "27681414235104944"
},
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "bla"
}
],
"messages": [
{
"from": "bla",
"id": "external_id",
"timestamp": "1454119029",
"text": {
"body": "Hello World"
},
"type": "text"
}
]
},
"field": "messages"
}
]
}
]
}
Loading

0 comments on commit e223a2e

Please sign in to comment.