github.com/schmorrison/Zoho@v1.1.4/recruit/contacts.go (about) 1 package recruit 2 3 import ( 4 "fmt" 5 6 zoho "github.com/schmorrison/Zoho" 7 ) 8 9 // GetContactsRecords returns a list of all records 10 // https://www.zoho.com/recruit/developer-guide/apiv2/get-records.html 11 // https://recruit.zoho.eu/recruit/v2/Contacts 12 func (c *API) GetContactsRecords( 13 params map[string]zoho.Parameter, 14 ) (data ContactsRecordsResponse, err error) { 15 endpoint := zoho.Endpoint{ 16 Name: "GetContactsRecords", 17 URL: fmt.Sprintf( 18 "https://recruit.zoho.%s/recruit/v2/%s", 19 c.ZohoTLD, 20 ContactsModule, 21 ), 22 Method: zoho.HTTPGet, 23 ResponseData: &ContactsRecordsResponse{}, 24 URLParameters: map[string]zoho.Parameter{ 25 "fields": "", 26 "sort_order": "", 27 "sort_by": "", 28 "converted": "false", 29 "approved": "true", 30 "page": "1", 31 "per_page": "200", 32 "cvid": "", 33 "territory_id": "", 34 "include_child": "", 35 }, 36 } 37 38 if len(params) > 0 { 39 for k, v := range params { 40 endpoint.URLParameters[k] = v 41 } 42 } 43 44 err = c.Zoho.HTTPRequest(&endpoint) 45 if err != nil { 46 return ContactsRecordsResponse{}, fmt.Errorf("failed to retrieve Contacts: %s", err) 47 } 48 49 if v, ok := endpoint.ResponseData.(*ContactsRecordsResponse); ok { 50 return *v, nil 51 } 52 53 return ContactsRecordsResponse{}, fmt.Errorf("data returned was not 'ContactsRecordsResponse'") 54 } 55 56 // GetContactsRecord returns the record specified by ID 57 // https://www.zoho.com/recruit/developer-guide/apiv2/get-records.html 58 // https://recruit.zoho.eu/recruit/v2/Contacts/{id} 59 func (c *API) GetContactsRecordById(id string) (data ContactsRecordsResponse, err error) { 60 endpoint := zoho.Endpoint{ 61 Name: "GetContactsRecordById", 62 URL: fmt.Sprintf( 63 "https://recruit.zoho.%s/recruit/v2/%s/%s", 64 c.ZohoTLD, 65 ContactsModule, 66 id, 67 ), 68 Method: zoho.HTTPGet, 69 ResponseData: &ContactsRecordsResponse{}, 70 } 71 72 err = c.Zoho.HTTPRequest(&endpoint) 73 if err != nil { 74 return ContactsRecordsResponse{}, fmt.Errorf( 75 "failed to retrieve JobOpening with id: %s", 76 err, 77 ) 78 } 79 80 if v, ok := endpoint.ResponseData.(*ContactsRecordsResponse); ok { 81 return *v, nil 82 } 83 84 return ContactsRecordsResponse{}, fmt.Errorf("data returned was not 'ContactsRecordsResponse'") 85 } 86 87 // ContactsRecordsResponse is the data returned by GetContactsRecords & GetContactsRecordById 88 type ContactsRecordsResponse struct { 89 Data []struct { 90 Salary string `json:"Salary,omitempty"` 91 ClientName struct { 92 Name string `json:"name,omitempty"` 93 ID string `json:"id,omitempty"` 94 } `json:"Client_Name,omitempty"` 95 Email string `json:"Email,omitempty"` 96 CurrencySymbol string `json:"$currency_symbol,omitempty"` 97 MailingZip string `json:"Mailing_Zip,omitempty"` 98 IsPrimaryContact bool `json:"Is_primary_contact,omitempty"` 99 MailingState string `json:"Mailing_State,omitempty"` 100 Twitter string `json:"Twitter,omitempty"` 101 OtherZip string `json:"Other_Zip,omitempty"` 102 MailingStreet string `json:"Mailing_Street,omitempty"` 103 OtherState string `json:"Other_State,omitempty"` 104 Salutation string `json:"Salutation,omitempty"` 105 OtherCountry string `json:"Other_Country,omitempty"` 106 Source string `json:"Source,omitempty"` 107 LastActivityTime Time `json:"Last_Activity_Time,omitempty"` 108 FirstName string `json:"First_Name,omitempty"` 109 FullName string `json:"Full_Name,omitempty"` 110 Department string `json:"Department,omitempty"` 111 ModifiedBy struct { 112 Name string `json:"name,omitempty"` 113 ID string `json:"id,omitempty"` 114 } `json:"Modified_By,omitempty"` 115 SkypeID string `json:"Skype_ID,omitempty"` 116 ProcessFlow bool `json:"$process_flow,omitempty"` 117 WorkPhone string `json:"Work_Phone,omitempty"` 118 MailingCountry string `json:"Mailing_Country,omitempty"` 119 ID string `json:"id,omitempty"` 120 EmailOptOut bool `json:"Email_Opt_Out,omitempty"` 121 Approved bool `json:"$approved,omitempty"` 122 Approval struct { 123 Delegate bool `json:"delegate,omitempty"` 124 Approve bool `json:"approve,omitempty"` 125 Reject bool `json:"reject,omitempty"` 126 Resubmit bool `json:"resubmit,omitempty"` 127 } `json:"$approval,omitempty"` 128 IsStatusSplitDone bool `json:"isStatusSplitDone,omitempty"` 129 ModifiedTime Time `json:"Modified_Time,omitempty"` 130 MailingCity string `json:"Mailing_City,omitempty"` 131 LastMailedTime string `json:"Last_Mailed_Time,omitempty"` 132 OtherCity string `json:"Other_City,omitempty"` 133 CreatedTime Time `json:"Created_Time,omitempty"` 134 ClientPortalUserStatus string `json:"Client_Portal_User_Status,omitempty"` 135 Followed bool `json:"$followed,omitempty"` 136 Editable bool `json:"$editable,omitempty"` 137 OtherStreet string `json:"Other_Street,omitempty"` 138 JobTitle string `json:"Job_Title,omitempty"` 139 Mobile string `json:"Mobile,omitempty"` 140 AssociatedTags []struct{} `json:"Associated_Tags,omitempty"` 141 ContactOwner struct { 142 Name string `json:"name,omitempty"` 143 ID string `json:"id,omitempty"` 144 } `json:"Contact_Owner,omitempty"` 145 LastName string `json:"Last_Name,omitempty"` 146 AssociatedAnySocialProfiles bool `json:"Associated_any_Social_Profiles,omitempty"` 147 CreatedBy struct { 148 Name string `json:"name,omitempty"` 149 ID string `json:"id,omitempty"` 150 } `json:"Created_By,omitempty"` 151 Fax string `json:"Fax,omitempty"` 152 SecondaryEmail string `json:"Secondary_Email,omitempty"` 153 IsAttachmentPresent bool `json:"Is_Attachment_Present,omitempty"` 154 } `json:"data,omitempty"` 155 Info PageInfo `json:"info,omitempty"` 156 }