summaryrefslogtreecommitdiffstats
path: root/js/dav/lib/model.js
blob: f2098af15b327070bb20255fe9f66bed41adb305 (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
export class Account {
  constructor(options) {
    Object.assign(this, {
      server: null,
      credentials: null,
      rootUrl: null,
      principalUrl: null,
      homeUrl: null,
      calendars: null,
      addressBooks: null
    }, options);
  }
}

/**
 * Options:
 *   (String) username - username (perhaps email) for calendar user.
 *   (String) password - plaintext password for calendar user.
 *   (String) clientId - oauth client id.
 *   (String) clientSecret - oauth client secret.
 *   (String) authorizationCode - oauth code.
 *   (String) redirectUrl - oauth redirect url.
 *   (String) tokenUrl - oauth token url.
 *   (String) accessToken - oauth access token.
 *   (String) refreshToken - oauth refresh token.
 *   (Number) expiration - unix time for access token expiration.
 */
export class Credentials {
  constructor(options) {
    Object.assign(this, {
      username: null,
      password: null,
      clientId: null,
      clientSecret: null,
      authorizationCode: null,
      redirectUrl: null,
      tokenUrl: null,
      accessToken: null,
      refreshToken: null,
      expiration: null
    }, options);
  }
}

export class DAVCollection {
  constructor(options) {
    Object.assign(this, {
      data: null,
      objects: null,
      account: null,
      ctag: null,
      description: null,
      displayName: null,
      reports: null,
      resourcetype: null,
      syncToken: null,
      url: null
    }, options);
  }
}

export class AddressBook extends DAVCollection {
  constructor(options) {
    super(options);
  }
}

export class Calendar extends DAVCollection {
  constructor(options) {
    super(options);
    Object.assign(this, {
      components: null,
      timezone: null
    }, options);
  }
}

export class DAVObject {
  constructor(options) {
    Object.assign(this, {
      data: null,
      etag: null,
      url: null
    }, options);
  }
}

export class CalendarObject extends DAVObject {
  constructor(options) {
    super(options);
    Object.assign(this, {
      calendar: null,
      calendarData: null
    }, options);
  }
}

export class VCard extends DAVObject {
  constructor(options) {
    super(options);
    Object.assign(this, {
      addressBook: null,
      addressData: null
    }, options);
  }
}