PlainApp
API 參考

聯絡人

透過 app.capabilities 判斷功能支援,透過 app.access 和主機權限判斷存取授權。範例使用合成值;呼叫前請替換路徑、ID、輸入和篩選條件。

型別定義

graphql
type Mutation {
  createContact(input: ContactInput!): Contact!
  createContactGroup(name: String!, accountName: String!, accountType: String!): ContactGroup!
  deleteContactGroup(id: ID!): Boolean!
  deleteContacts(query: String!): ActionResult!
  updateContact(id: ID!, input: ContactInput!): Contact!
  updateContactGroup(id: ID!, name: String!): ContactGroup!
}

type Query {
  contactCount(query: String!): Int!
  contactGroups: [ContactGroup!]!
  contactSources: [ContactSource!]!
  contacts(query: String!, offset: Int!, limit: Int!): [Contact!]!
}

type ActionResult {
	affectedCount: Int!
}

type Contact {
	id: ID!
	prefix: String!
	firstName: String!
	middleName: String!
	lastName: String!
	suffix: String!
	nickname: String!
	photoId: String!
	phoneNumbers: [ContactPhoneNumber!]!
	emails: [ContactEmail!]!
	addresses: [ContactAddress!]!
	events: [ContactEvent!]!
	source: String!
	starred: Boolean!
	contactId: ID!
	thumbnailId: String!
	notes: String!
	groups: [ContactGroup!]!
	organization: ContactOrganization
	websites: [ContactWebsite!]!
	ims: [ContactIm!]!
	ringtone: String!
	updatedAt: Instant!
	tags: [Tag!]!
}

type ContactAddress {
	typeCode: Int!
	value: String!
	type: ContactPostalType!
	label: String!
}

input ContactAddressInput {
	value: String!
	type: ContactPostalType!
	label: String!
}

type ContactEmail {
	typeCode: Int!
	value: String!
	type: ContactEmailType!
	label: String!
}

input ContactEmailInput {
	value: String!
	type: ContactEmailType!
	label: String!
}

enum ContactEmailType {
	CUSTOM
	HOME
	WORK
	OTHER
	MOBILE
}

type ContactEvent {
	typeCode: Int!
	value: String!
	type: ContactEventType!
	label: String!
}

input ContactEventInput {
	value: String!
	type: ContactEventType!
	label: String!
}

enum ContactEventType {
	CUSTOM
	ANNIVERSARY
	BIRTHDAY
	OTHER
}

type ContactGroup {
	id: ID!
	name: String!
	contactCount: Int!
}

type ContactIm {
	typeCode: Int!
	value: String!
	protocol: ContactImProtocol!
	customProtocol: String!
}

input ContactImInput {
	value: String!
	protocol: ContactImProtocol!
	customProtocol: String!
}

enum ContactImProtocol {
	CUSTOM
	AIM
	MSN
	YAHOO
	SKYPE
	QQ
	GOOGLE_TALK
	ICQ
	JABBER
	NETMEETING
}

input ContactInput {
	prefix: String!
	firstName: String!
	middleName: String!
	lastName: String!
	suffix: String!
	nickname: String!
	phoneNumbers: [ContactPhoneInput!]!
	emails: [ContactEmailInput!]!
	addresses: [ContactAddressInput!]!
	events: [ContactEventInput!]!
	source: String!
	starred: Boolean!
	notes: String!
	groupIds: [ID!]!
	organization: ContactOrganizationInput
	websites: [ContactWebsiteInput!]!
	ims: [ContactImInput!]!
}

type ContactOrganization {
	company: String!
	title: String!
}

input ContactOrganizationInput {
	company: String!
	title: String!
}

input ContactPhoneInput {
	value: String!
	type: ContactPhoneType!
	label: String!
}

type ContactPhoneNumber {
	typeCode: Int!
	value: String!
	type: ContactPhoneType!
	label: String!
	normalizedNumber: String!
}

enum ContactPhoneType {
	CUSTOM
	HOME
	MOBILE
	WORK
	FAX_WORK
	FAX_HOME
	PAGER
	OTHER
	CALLBACK
	CAR
	COMPANY_MAIN
	ISDN
	MAIN
	OTHER_FAX
	RADIO
	TELEX
	TTY_TDD
	WORK_MOBILE
	WORK_PAGER
	ASSISTANT
}

enum ContactPostalType {
	CUSTOM
	HOME
	WORK
	OTHER
}

type ContactSource {
	name: String!
	type: String!
}

type ContactWebsite {
	typeCode: Int!
	value: String!
	type: ContactWebsiteType!
	label: String!
}

input ContactWebsiteInput {
	value: String!
	type: ContactWebsiteType!
	label: String!
}

enum ContactWebsiteType {
	CUSTOM
	HOMEPAGE
	BLOG
	FTP
	HOME
	WORK
	OTHER
}

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

scalar Instant

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

操作

mutation

createContact

建立聯絡人。

graphql
mutation createContact($input: ContactInput!) {
  createContact(input: $input) { id prefix firstName middleName lastName suffix nickname photoId }
}
mutation

createContactGroup

在指定帳戶中建立聯絡人分組。

graphql
mutation createContactGroup($name: String!, $accountName: String!, $accountType: String!) {
  createContactGroup(name: $name, accountName: $accountName, accountType: $accountType) { id name contactCount }
}
mutation

deleteContactGroup

刪除聯絡人分組;組內聯絡人僅取消分組,不會被刪除。

graphql
mutation deleteContactGroup($id: ID!) {
  deleteContactGroup(id: $id)
}
mutation

deleteContacts

刪除所有符合查詢條件的聯絡人。

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

updateContact

更新已有聯絡人,僅修改傳入的欄位。

graphql
mutation updateContact($id: ID!, $input: ContactInput!) {
  updateContact(id: $id, input: $input) { id prefix firstName middleName lastName suffix nickname photoId }
}
mutation

updateContactGroup

重新命名聯絡人分組。

graphql
mutation updateContactGroup($id: ID!, $name: String!) {
  updateContactGroup(id: $id, name: $name) { id name contactCount }
}
query

contactCount

統計符合查詢條件的聯絡人數。

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

contactGroups

列出全部聯絡人分組。

graphql
query contactGroups {
  contactGroups { id name contactCount }
}
query

contactSources

列出可用的聯絡人帳戶來源。

graphql
query contactSources {
  contactSources { name type }
}
query

contacts

搜尋聯絡人;query 留空時列出全部聯絡人。

graphql
query contacts($query: String!, $offset: Int!, $limit: Int!) {
  contacts(query: $query, offset: $offset, limit: $limit) { id prefix firstName middleName lastName suffix nickname photoId }
}