-
Notifications
You must be signed in to change notification settings - Fork 21
/
live_photos.go
51 lines (44 loc) · 1.36 KB
/
live_photos.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package onfido
import (
"encoding/json"
"time"
)
// LivePhoto represents a LivePhoto in Onfido API
type LivePhoto struct {
ID string `json:"id,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
Href string `json:"href,omitempty"`
DownloadHref string `json:"download_href,omitempty"`
FileName string `json:"file_name,omitempty"`
FileType string `json:"file_type,omitempty"`
FileSize int32 `json:"file_size,omitempty"`
}
// LivePhotoIter represents a LivePhoto iterator
type LivePhotoIter struct {
*iter
}
// LivePhoto returns the current item in the iterator as a LivePhoto.
func (i *LivePhotoIter) LivePhoto() *LivePhoto {
return i.Current().(*LivePhoto)
}
// ListPhotos retrieves the list of photos for the provided applicant.
// see https://documentation.onfido.com/?shell#live-photos
func (c *Client) ListLivePhotos(applicantID string) *LivePhotoIter {
return &LivePhotoIter{&iter{
c: c,
nextURL: "/live_photos?applicant_id=" + applicantID,
handler: func(body []byte) ([]interface{}, error) {
var r struct {
LivePhotos []*LivePhoto `json:"live_photos"`
}
if err := json.Unmarshal(body, &r); err != nil {
return nil, err
}
values := make([]interface{}, len(r.LivePhotos))
for i, v := range r.LivePhotos {
values[i] = v
}
return values, nil
},
}}
}