mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27:52 +00:00
Fix: Accept phone number in public contact api (#4580)
This PR makes it possible to pass a phone number to the public contacts API. Fixes #4023
This commit is contained in:
@@ -43,6 +43,6 @@ class Public::Api::V1::Inboxes::ContactsController < Public::Api::V1::InboxesCon
|
|||||||
end
|
end
|
||||||
|
|
||||||
def permitted_params
|
def permitted_params
|
||||||
params.permit(:identifier, :identifier_hash, :email, :name, :avatar_url, custom_attributes: {})
|
params.permit(:identifier, :identifier_hash, :email, :name, :avatar_url, :phone_number, custom_attributes: {})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
json.id resource.id
|
json.id resource.id
|
||||||
json.name resource.name
|
json.name resource.name
|
||||||
json.email resource.email
|
json.email resource.email
|
||||||
|
json.phone_number resource.phone_number
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ RSpec.describe 'Public Inbox Contacts API', type: :request do
|
|||||||
post "/public/api/v1/inboxes/#{api_channel.identifier}/contacts"
|
post "/public/api/v1/inboxes/#{api_channel.identifier}/contacts"
|
||||||
|
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
data = JSON.parse(response.body)
|
data = response.parsed_body
|
||||||
|
expect(data.keys).to include('email', 'id', 'name', 'phone_number', 'pubsub_token', 'source_id')
|
||||||
expect(data['source_id']).not_to eq nil
|
expect(data['source_id']).not_to eq nil
|
||||||
expect(data['pubsub_token']).not_to eq nil
|
expect(data['pubsub_token']).not_to eq nil
|
||||||
end
|
end
|
||||||
@@ -21,7 +22,8 @@ RSpec.describe 'Public Inbox Contacts API', type: :request do
|
|||||||
get "/public/api/v1/inboxes/#{api_channel.identifier}/contacts/#{contact_inbox.source_id}"
|
get "/public/api/v1/inboxes/#{api_channel.identifier}/contacts/#{contact_inbox.source_id}"
|
||||||
|
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
data = JSON.parse(response.body)
|
data = response.parsed_body
|
||||||
|
expect(data.keys).to include('email', 'id', 'name', 'phone_number', 'pubsub_token', 'source_id')
|
||||||
expect(data['source_id']).to eq contact_inbox.source_id
|
expect(data['source_id']).to eq contact_inbox.source_id
|
||||||
expect(data['pubsub_token']).to eq contact_inbox.pubsub_token
|
expect(data['pubsub_token']).to eq contact_inbox.pubsub_token
|
||||||
end
|
end
|
||||||
@@ -33,7 +35,7 @@ RSpec.describe 'Public Inbox Contacts API', type: :request do
|
|||||||
params: { name: 'John Smith' }
|
params: { name: 'John Smith' }
|
||||||
|
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
data = JSON.parse(response.body)
|
data = response.parsed_body
|
||||||
expect(data['name']).to eq 'John Smith'
|
expect(data['name']).to eq 'John Smith'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,9 +10,12 @@ properties:
|
|||||||
email:
|
email:
|
||||||
type: string
|
type: string
|
||||||
description: Email of the contact
|
description: Email of the contact
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
description: Name of the contact
|
description: Name of the contact
|
||||||
|
phone_number:
|
||||||
|
type: string
|
||||||
|
description: Phone number of the contact
|
||||||
avatar_url:
|
avatar_url:
|
||||||
type: string
|
type: string
|
||||||
description: The url to a jpeg, png file for the user avatar
|
description: The url to a jpeg, png file for the user avatar
|
||||||
|
|||||||
@@ -5268,6 +5268,10 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Name of the contact"
|
"description": "Name of the contact"
|
||||||
},
|
},
|
||||||
|
"phone_number": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Phone number of the contact"
|
||||||
|
},
|
||||||
"avatar_url": {
|
"avatar_url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The url to a jpeg, png file for the user avatar"
|
"description": "The url to a jpeg, png file for the user avatar"
|
||||||
|
|||||||
Reference in New Issue
Block a user