Tham chiếu API

SMS

SMS and MMS APIs.

Định nghĩa kiểu

graphql
type Subscription {
  smsChanged: SmsProviderChange
  smsSendResult: SmsSendResult!
}

type Mutation {
  archiveSmsConversation(id: ID!, date: Instant): Boolean!
  deleteSms(query: String!): ActionResult!
  restoreSms(query: String!): ActionResult!
  sendSms(number: String!, body: String!, attachmentPaths: [String!]! = [], subscriptionId: Int, requestId: String!): SmsSendReceipt!
  trashSms(query: String!): ActionResult!
  unarchiveSmsConversation(id: ID!): Boolean!
}

type Query {
  archivedSmsConversations(query: String!, offset: Int!, limit: Int!): [SmsConversation!]!
  sims: [Sim!]!
  sms(query: String!, offset: Int!, limit: Int!): [Sms!]!
  smsBoxCounts: SmsCounts!
  smsConversationCount(query: String!): Int!
  smsConversations(query: String!, offset: Int!, limit: Int!): [SmsConversation!]!
  smsCount(query: String!): Int!
}

type ActionResult {
	affectedCount: Int!
}

enum DataType {
	DEFAULT
	AUDIO
	VIDEO
	IMAGE
	SMS
	CONTACT
	NOTE
	FEED_ENTRY
	CALL
	PACKAGE
	FILE
	APP_FILE
	DOC
}

scalar Instant

type Sim {
	id: ID!
	label: String!
	number: String!
	subscriptionId: Int!
}

type Sms {
	id: ID!
	body: String!
	address: String!
	sentAt: Instant!
	serviceCenter: String!
	read: Boolean!
	threadId: ID!
	type: SmsType!
	typeCode: Int!
	subscriptionId: Int!
	isMms: Boolean!
	attachments: [SmsAttachment!]!
	tags: [Tag!]!
}

type SmsAttachment {
	path: String!
	contentType: String!
	name: String!
}

type SmsConversation {
	id: ID!
	address: String!
	snippet: String!
	lastMessageAt: Instant!
	messageCount: Int!
	read: Boolean!
	addresses: [String!]!
}

type SmsCounts {
	total: Int!
	inbox: Int!
	sent: Int!
	drafts: Int!
}

type SmsProviderChange {
	uris: [String!]!
}

type SmsSendReceipt {
	requestId: String!
	requiresConfirmation: Boolean!
}

type SmsSendResult {
	requestId: String!
	success: Boolean!
	resultCode: Int
}

enum SmsType {
	INBOX
	SENT
	DRAFT
	OUTBOX
	FAILED
	QUEUED
	UNKNOWN
}

type Tag {
	id: ID!
	name: String!
	type: DataType!
	count: Int!
}

Thao tác

subscription

smsChanged

Thông báo cho ứng dụng làm mới danh sách SMS khi tin nhắn trên thiết bị thay đổi. Không trả về nội dung tin nhắn.

graphql
subscription smsChanged {
  smsChanged { uris }
}
subscription

smsSendResult

Nhận kết quả gửi SMS/MMS và đối chiếu bằng requestId. Dùng success để xác định kết quả: SMS thành công là -1; MMS thành công là 0, hết hạn là -1000, hủy là -1001. Gửi thành công không xác nhận đã chuyển đến người nhận.

graphql
subscription smsSendResult {
  smsSendResult { requestId success resultCode }
}
mutation

archiveSmsConversation

Lưu trữ hội thoại tin nhắn, có thể ghi ngày lưu trữ.

graphql
mutation archiveSmsConversation($id: ID!, $date: Instant) {
  archiveSmsConversation(id: $id, date: $date)
}
mutation

deleteSms

Xóa vĩnh viễn SMS khớp truy vấn.

graphql
mutation deleteSms($query: String!) {
  deleteSms(query: $query) { affectedCount }
}
mutation

restoreSms

Khôi phục SMS trong thùng rác khớp truy vấn.

graphql
mutation restoreSms($query: String!) {
  restoreSms(query: $query) { affectedCount }
}
mutation

sendSms

Gửi SMS hoặc mở trình soạn MMS trên điện thoại với tệp đính kèm.

graphql
mutation sendSms($number: String!, $body: String!, $attachmentPaths: [String!]!, $subscriptionId: Int, $requestId: String!) {
  sendSms(number: $number, body: $body, attachmentPaths: $attachmentPaths, subscriptionId: $subscriptionId, requestId: $requestId) { requestId requiresConfirmation }
}
mutation

trashSms

Chuyển SMS khớp truy vấn vào thùng rác.

graphql
mutation trashSms($query: String!) {
  trashSms(query: $query) { affectedCount }
}
mutation

unarchiveSmsConversation

Bỏ trạng thái lưu trữ của hội thoại.

graphql
mutation unarchiveSmsConversation($id: ID!) {
  unarchiveSmsConversation(id: $id)
}
query

archivedSmsConversations

Tìm hội thoại SMS đã lưu trữ có phân trang.

graphql
query archivedSmsConversations($query: String!, $offset: Int!, $limit: Int!) {
  archivedSmsConversations(query: $query, offset: $offset, limit: $limit) { id address snippet lastMessageAt messageCount read addresses }
}
query

sims

Liệt kê các thẻ SIM và tài khoản điện thoại có sẵn trên thiết bị.

graphql
query sims {
  sims { id label number subscriptionId }
}
query

sms

Tìm SMS. Dùng chuỗi query rỗng để liệt kê tất cả.

graphql
query sms($query: String!, $offset: Int!, $limit: Int!) {
  sms(query: $query, offset: $offset, limit: $limit) { id body address sentAt serviceCenter read threadId type }
}
query

smsBoxCounts

Đọc số tin nhắn trong các hộp SMS có sẵn.

graphql
query smsBoxCounts {
  smsBoxCounts { total inbox sent drafts }
}
query

smsConversationCount

Đếm hội thoại SMS khớp truy vấn.

graphql
query smsConversationCount($query: String!) {
  smsConversationCount(query: $query)
}
query

smsConversations

Liệt kê hội thoại (chuỗi) SMS có phân trang.

graphql
query smsConversations($query: String!, $offset: Int!, $limit: Int!) {
  smsConversations(query: $query, offset: $offset, limit: $limit) { id address snippet lastMessageAt messageCount read addresses }
}
query

smsCount

Đếm SMS khớp truy vấn.

graphql
query smsCount($query: String!) {
  smsCount(query: $query)
}