summaryrefslogtreecommitdiff
path: root/ui/app/models/provider.js
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-09-21 15:39:03 -0700
committerKali Kaneko (leap communications) <kali@leap.se>2016-09-22 11:40:14 -0400
commit7569ac8bd58174095f3f897548e26d0ba905236c (patch)
tree839c300d7dff62900bcc91672a3b55cf62c31f6c /ui/app/models/provider.js
parent61b5734c12d6ab6733d3a832df8d99f1041bf355 (diff)
[feat] the setup wizard for the new ui
Diffstat (limited to 'ui/app/models/provider.js')
-rw-r--r--ui/app/models/provider.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/ui/app/models/provider.js b/ui/app/models/provider.js
new file mode 100644
index 0000000..2ed2dc8
--- /dev/null
+++ b/ui/app/models/provider.js
@@ -0,0 +1,59 @@
+import bitmask from 'lib/bitmask'
+
+var LOCALE = 'en'
+
+export default class Provider {
+
+ constructor(props) {
+ this._name = props.name
+ this._description = props.description
+ let k = null
+ for (k in props) {
+ if (k != 'description' && k != 'name') {
+ this[k] = props[k]
+ }
+ }
+ }
+
+ get name() {
+ return this._name[LOCALE]
+ }
+
+ get description() {
+ return this._description[LOCALE]
+ }
+
+ static setup(domain) {
+ return bitmask.bonafide.provider.create(domain).then(
+ response => {
+ console.log("Provider configured: " + response.domain)
+ return new Provider(response)
+ }
+ )
+ }
+
+ static get(domain) {
+ return bitmask.bonafide.provider.read(domain).then(
+ response => {
+ return new Provider(response)
+ }
+ )
+ }
+
+ static list(seeded=false) {
+ return bitmask.bonafide.provider.list(seeded).then(
+ response => {
+ return response.map(
+ i => { return i['domain'] }
+ )
+ }
+ )
+ }
+
+ static delete(domain) {
+ return bitmask.bonafide.provider.delete(domain)
+ }
+}
+
+
+