func (p *SmugMugContactService) RetrieveContact(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, contactId string) (*Contact, os.Error) { extContact, err := smugmug.RetrieveUserInfo(client, contactId, nil) if extContact == nil || err != nil { return nil, err } return p.handleRetrievedContact(client, ds, dsocialUserId, contactId, &extContact.User) }
func (p *SmugMugContactService) RetrieveContacts(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Contact, NextToken, os.Error) { l := list.New() var useErr os.Error famResp, err := smugmug.RetrieveFamily(client, nil) if err != nil { useErr = err } if famResp != nil && famResp.Family != nil { for _, u := range famResp.Family { contact, err := p.handleRetrievedContact(client, ds, dsocialUserId, u.NickName, &u) if contact != nil { l.PushBack(contact) } if err != nil && useErr == nil { useErr = err } } } if useErr != nil { return p.listToContacts(l), nil, useErr } fansResp, err := smugmug.RetrieveFans(client, nil) if err != nil { useErr = err } if fansResp != nil && fansResp.Fans != nil { for _, u := range fansResp.Fans { contact, err := p.handleRetrievedContact(client, ds, dsocialUserId, u.NickName, &u) if contact != nil { l.PushBack(contact) } if err != nil && useErr == nil { useErr = err } } } if useErr != nil { return p.listToContacts(l), nil, useErr } userInfo, err := client.RetrieveUserInfo() if err != nil { return p.listToContacts(l), nil, err } userResp, err := smugmug.RetrieveUserInfo(client, userInfo.Username(), nil) if err != nil { useErr = err } if userResp != nil { contact, err := p.handleRetrievedContact(client, ds, dsocialUserId, userResp.User.NickName, &userResp.User) if contact != nil { l.PushBack(contact) } if err != nil && useErr == nil { useErr = err } } return p.listToContacts(l), nil, useErr }