|  | 
|  | 1 | +import { axios } from "@pipedream/platform"; | 
|  | 2 | + | 
| 1 | 3 | export default { | 
| 2 | 4 |   type: "app", | 
| 3 | 5 |   app: "cliento", | 
| 4 |  | -  propDefinitions: {}, | 
|  | 6 | +  propDefinitions: { | 
|  | 7 | +    fromDate: { | 
|  | 8 | +      type: "string", | 
|  | 9 | +      label: "From Date", | 
|  | 10 | +      description: "The start date for the booking period (format: YYYY-MM-DD)", | 
|  | 11 | +    }, | 
|  | 12 | +    toDate: { | 
|  | 13 | +      type: "string", | 
|  | 14 | +      label: "To Date", | 
|  | 15 | +      description: "The end date for the booking period (format: YYYY-MM-DD)", | 
|  | 16 | +    }, | 
|  | 17 | +    resourceIds: { | 
|  | 18 | +      type: "string[]", | 
|  | 19 | +      label: "Resource IDs", | 
|  | 20 | +      description: "The IDs of the resources for the booking", | 
|  | 21 | +      async options() { | 
|  | 22 | +        const { resources } = await this.fetchRefData(); | 
|  | 23 | +        return resources?.map(({ | 
|  | 24 | +          id: value, name: label, | 
|  | 25 | +        }) => ({ | 
|  | 26 | +          value, | 
|  | 27 | +          label, | 
|  | 28 | +        })) || []; | 
|  | 29 | +      }, | 
|  | 30 | +    }, | 
|  | 31 | +    serviceIds: { | 
|  | 32 | +      type: "string[]", | 
|  | 33 | +      label: "Service IDs", | 
|  | 34 | +      description: "The IDs of the services for the booking", | 
|  | 35 | +      async options() { | 
|  | 36 | +        const { services } = await this.fetchRefData(); | 
|  | 37 | +        return services?.map(({ | 
|  | 38 | +          serviceId: value, name: label, | 
|  | 39 | +        }) => ({ | 
|  | 40 | +          value, | 
|  | 41 | +          label, | 
|  | 42 | +        })) || []; | 
|  | 43 | +      }, | 
|  | 44 | +    }, | 
|  | 45 | +  }, | 
| 5 | 46 |   methods: { | 
| 6 |  | -    // this.$auth contains connected account data | 
| 7 |  | -    authKeys() { | 
| 8 |  | -      console.log(Object.keys(this.$auth)); | 
|  | 47 | +    _baseUrl() { | 
|  | 48 | +      return `https://cliento.com/api/v2/partner/cliento/${this.$auth.account_id}`; | 
|  | 49 | +    }, | 
|  | 50 | +    _makeRequest(opts = {}) { | 
|  | 51 | +      const { | 
|  | 52 | +        $ = this, | 
|  | 53 | +        path, | 
|  | 54 | +        ...otherOpts | 
|  | 55 | +      } = opts; | 
|  | 56 | +      return axios($, { | 
|  | 57 | +        ...otherOpts, | 
|  | 58 | +        url: `${this._baseUrl()}${path}`, | 
|  | 59 | +        headers: { | 
|  | 60 | +          Accept: "application/json", | 
|  | 61 | +        }, | 
|  | 62 | +      }); | 
|  | 63 | +    }, | 
|  | 64 | +    fetchSettings(opts = {}) { | 
|  | 65 | +      return this._makeRequest({ | 
|  | 66 | +        path: "/settings/", | 
|  | 67 | +        ...opts, | 
|  | 68 | +      }); | 
|  | 69 | +    }, | 
|  | 70 | +    fetchRefData(opts = {}) { | 
|  | 71 | +      return this._makeRequest({ | 
|  | 72 | +        path: "/ref-data/", | 
|  | 73 | +        ...opts, | 
|  | 74 | +      }); | 
|  | 75 | +    }, | 
|  | 76 | +    fetchSlots(opts = {}) { | 
|  | 77 | +      return this._makeRequest({ | 
|  | 78 | +        path: "/resources/slots", | 
|  | 79 | +        ...opts, | 
|  | 80 | +      }); | 
| 9 | 81 |     }, | 
| 10 | 82 |   }, | 
| 11 | 83 | }; | 
0 commit comments