diff --git a/canopeum_backend/canopeum_backend/migrations/0002_remove_post_share_count.py b/canopeum_backend/canopeum_backend/migrations/0002_remove_post_share_count.py
new file mode 100644
index 000000000..4fa060d3b
--- /dev/null
+++ b/canopeum_backend/canopeum_backend/migrations/0002_remove_post_share_count.py
@@ -0,0 +1,17 @@
+# Generated by Django 5.1 on 2024-11-26 18:33
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("canopeum_backend", "0001_initial"),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name="post",
+ name="share_count",
+ ),
+ ]
diff --git a/canopeum_backend/test.py b/canopeum_backend/test.py
index ff81fdd16..cc4b9ff0e 100644
--- a/canopeum_backend/test.py
+++ b/canopeum_backend/test.py
@@ -18,4 +18,8 @@ def test_no_pending_migrations(self):
stderr=StringIO(),
)
except SystemExit:
- raise AssertionError("Pending migrations:\n" + out.getvalue()) from None
+ raise AssertionError(
+ "Pending migrations:\n"
+ + out.getvalue()
+ + "\nPlease run `uv run manage.py makemigrations`"
+ ) from None
diff --git a/canopeum_frontend/.eslintrc.cjs b/canopeum_frontend/.eslintrc.cjs
index fde6f4f1c..ae81c6e53 100644
--- a/canopeum_frontend/.eslintrc.cjs
+++ b/canopeum_frontend/.eslintrc.cjs
@@ -10,7 +10,7 @@ module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
projectService: {
- allowDefaultProject: ['*/*/*.js', '.eslintrc.cjs'],
+ allowDefaultProject: ['*/*/*.js', '.eslintrc.cjs', 'apiSchemaGenerator.js'],
},
// Still needed for plugins that haven't updated to typescript-eslint@8 yet
// Namely: eslint-plugin-sonarjs
diff --git a/canopeum_frontend/apiSchemaGenerator.js b/canopeum_frontend/apiSchemaGenerator.js
index 65db48098..7dd7e9455 100644
--- a/canopeum_frontend/apiSchemaGenerator.js
+++ b/canopeum_frontend/apiSchemaGenerator.js
@@ -6,7 +6,7 @@ import * as url from 'node:url'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
const schemaUrl = 'http://127.0.0.1:8000/api/schema/'
const outputPath = path.join(__dirname, 'openapi.yaml')
-const nswagPath = path.join(__dirname, '../../..', 'docs/canopeum.nswag')
+const nswagPath = path.join(__dirname, '..', 'docs', 'canopeum.nswag')
const response = await fetch(schemaUrl)
if (!response.ok) {
diff --git a/canopeum_frontend/package-lock.json b/canopeum_frontend/package-lock.json
index 377f9dc84..b62c91612 100644
--- a/canopeum_frontend/package-lock.json
+++ b/canopeum_frontend/package-lock.json
@@ -38,7 +38,7 @@
"@types/react-transition-group": "^4.4.10",
"@vitejs/plugin-react": "^4.2.1",
"dprint": "^0.47.2",
- "eslint-config-beslogic": "^3.1.1",
+ "eslint-config-beslogic": "^3.1.2",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
@@ -7214,9 +7214,9 @@
}
},
"node_modules/eslint-config-beslogic": {
- "version": "3.1.1",
- "resolved": "https://registry.npmjs.org/eslint-config-beslogic/-/eslint-config-beslogic-3.1.1.tgz",
- "integrity": "sha512-/U6bDRLRI+hN6ZDfqeVBQ0zsjHhlaqdCNeZU45owZjoFBwab2VPno0IkBXUz6/LPrpMrI815XvUSLyFiD4OOBA==",
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/eslint-config-beslogic/-/eslint-config-beslogic-3.1.2.tgz",
+ "integrity": "sha512-+gZO5wShxJIxfKKeMp5i5nGphF9DhWlqmKYF+KlPdp788RryK6m5iur1nNM7x0wnT6cHKKkJE/2kAiqdxltmAQ==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
diff --git a/canopeum_frontend/package.json b/canopeum_frontend/package.json
index d5b0632fd..1c306149c 100644
--- a/canopeum_frontend/package.json
+++ b/canopeum_frontend/package.json
@@ -47,7 +47,7 @@
"@types/react-transition-group": "^4.4.10",
"@vitejs/plugin-react": "^4.2.1",
"dprint": "^0.47.2",
- "eslint-config-beslogic": "^3.1.1",
+ "eslint-config-beslogic": "^3.1.2",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
diff --git a/canopeum_frontend/src/components/social/SharePostDialog.tsx b/canopeum_frontend/src/components/social/SharePostDialog.tsx
index 492356231..23583d764 100644
--- a/canopeum_frontend/src/components/social/SharePostDialog.tsx
+++ b/canopeum_frontend/src/components/social/SharePostDialog.tsx
@@ -19,8 +19,7 @@ const SharePostDialog = ({ onClose, open, post }: Props) => {
const [shareUrl, setShareUrl] = useState('')
useEffect(
- () =>
- setShareUrl(`${globalThis.location.host}${appRoutes.postDetail(post.id)}`),
+ () => setShareUrl(`${globalThis.location.host}${appRoutes.postDetail(post.id)}`),
[post],
)
diff --git a/canopeum_frontend/src/services/api.ts b/canopeum_frontend/src/services/api.ts
index a1326f44d..892663ecd 100644
--- a/canopeum_frontend/src/services/api.ts
+++ b/canopeum_frontend/src/services/api.ts
@@ -1,6908 +1,6904 @@
-// ----------------------
-//
-// Generated using the NSwag toolchain v14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
-//
-// ----------------------
-
-/* tslint:disable */
-/* eslint-disable */
-// ReSharper disable InconsistentNaming
-
-export class AdminUserSitesClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- all(): Promise {
- let url_ = this.baseUrl + '/admin-user-sites/'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAll(_response)
- })
- }
-
- protected processAll(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(AdminUserSites.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class BatchClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- all(): Promise {
- let url_ = this.baseUrl + '/analytics/batches/'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAll(_response)
- })
- }
-
- protected processAll(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(BatchDetail.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- create(
- site?: number | undefined,
- name?: string | null | undefined,
- sponsorName?: string | null | undefined,
- sponsorWebsiteUrl?: string | null | undefined,
- sponsorLogo?: FileParameter | null | undefined,
- size?: number | null | undefined,
- soilCondition?: string | null | undefined,
- survivedCount?: number | null | undefined,
- replaceCount?: number | null | undefined,
- totalPropagation?: number | null | undefined,
- image?: FileParameter | null | undefined,
- fertilizerIds?: number[] | undefined,
- mulchLayerIds?: number[] | undefined,
- seeds?: Seeds[] | undefined,
- species?: Species[] | undefined,
- supportedSpecieIds?: number[] | undefined,
- ): Promise {
- let url_ = this.baseUrl + '/analytics/batches/'
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = new FormData()
- if (site === null || site === undefined) {
- throw new Error("The parameter 'site' cannot be null.")
- } else {
- content_.append('site', site.toString())
- }
- if (name !== null && name !== undefined) {
- content_.append('name', name.toString())
- }
- if (sponsorName !== null && sponsorName !== undefined) {
- content_.append('sponsorName', sponsorName.toString())
- }
- if (sponsorWebsiteUrl !== null && sponsorWebsiteUrl !== undefined) {
- content_.append('sponsorWebsiteUrl', sponsorWebsiteUrl.toString())
- }
- if (sponsorLogo !== null && sponsorLogo !== undefined) {
- content_.append(
- 'sponsorLogo',
- sponsorLogo.data,
- sponsorLogo.fileName ? sponsorLogo.fileName : 'sponsorLogo',
- )
- }
- if (size !== null && size !== undefined) {
- content_.append('size', size.toString())
- }
- if (soilCondition !== null && soilCondition !== undefined) {
- content_.append('soilCondition', soilCondition.toString())
- }
- if (survivedCount !== null && survivedCount !== undefined) {
- content_.append('survivedCount', survivedCount.toString())
- }
- if (replaceCount !== null && replaceCount !== undefined) {
- content_.append('replaceCount', replaceCount.toString())
- }
- if (totalPropagation !== null && totalPropagation !== undefined) {
- content_.append('totalPropagation', totalPropagation.toString())
- }
- if (image !== null && image !== undefined) {
- content_.append('image', image.data, image.fileName ? image.fileName : 'image')
- }
- if (fertilizerIds === null || fertilizerIds === undefined) {
- throw new Error("The parameter 'fertilizerIds' cannot be null.")
- } else {
- fertilizerIds.forEach(item_ => content_.append('fertilizerIds', item_.toString()))
- }
- if (mulchLayerIds === null || mulchLayerIds === undefined) {
- throw new Error("The parameter 'mulchLayerIds' cannot be null.")
- } else {
- mulchLayerIds.forEach(item_ => content_.append('mulchLayerIds', item_.toString()))
- }
- if (seeds === null || seeds === undefined) {
- throw new Error("The parameter 'seeds' cannot be null.")
- } else {
- seeds.forEach(item_ => content_.append('seeds', item_.toString()))
- }
- if (species === null || species === undefined) {
- throw new Error("The parameter 'species' cannot be null.")
- } else {
- species.forEach(item_ => content_.append('species', item_.toString()))
- }
- if (supportedSpecieIds === null || supportedSpecieIds === undefined) {
- throw new Error("The parameter 'supportedSpecieIds' cannot be null.")
- } else {
- supportedSpecieIds.forEach(item_ => content_.append('supportedSpecieIds', item_.toString()))
- }
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processCreate(_response)
- })
- }
-
- protected processCreate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 201) {
- return response.text().then(_responseText => {
- let result201: any = null
- let resultData201 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result201 = BatchDetail.fromJS(resultData201)
- return result201
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- update(
- batchId: number,
- name?: string | null | undefined,
- sponsorName?: string | null | undefined,
- sponsorWebsiteUrl?: string | null | undefined,
- sponsorLogo?: FileParameter | null | undefined,
- size?: number | null | undefined,
- soilCondition?: string | null | undefined,
- survivedCount?: number | null | undefined,
- replaceCount?: number | null | undefined,
- totalPropagation?: number | null | undefined,
- fertilizerIds?: number[] | undefined,
- mulchLayerIds?: number[] | undefined,
- seeds?: Seeds2[] | undefined,
- species?: Species2[] | undefined,
- supportedSpecieIds?: number[] | undefined,
- ): Promise {
- let url_ = this.baseUrl + '/analytics/batches/{batchId}/'
- if (batchId === undefined || batchId === null) {
- throw new Error("The parameter 'batchId' must be defined.")
- }
- url_ = url_.replace('{batchId}', encodeURIComponent('' + batchId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = new FormData()
- if (name !== null && name !== undefined) {
- content_.append('name', name.toString())
- }
- if (sponsorName !== null && sponsorName !== undefined) {
- content_.append('sponsorName', sponsorName.toString())
- }
- if (sponsorWebsiteUrl !== null && sponsorWebsiteUrl !== undefined) {
- content_.append('sponsorWebsiteUrl', sponsorWebsiteUrl.toString())
- }
- if (sponsorLogo !== null && sponsorLogo !== undefined) {
- content_.append(
- 'sponsorLogo',
- sponsorLogo.data,
- sponsorLogo.fileName ? sponsorLogo.fileName : 'sponsorLogo',
- )
- }
- if (size !== null && size !== undefined) {
- content_.append('size', size.toString())
- }
- if (soilCondition !== null && soilCondition !== undefined) {
- content_.append('soilCondition', soilCondition.toString())
- }
- if (survivedCount !== null && survivedCount !== undefined) {
- content_.append('survivedCount', survivedCount.toString())
- }
- if (replaceCount !== null && replaceCount !== undefined) {
- content_.append('replaceCount', replaceCount.toString())
- }
- if (totalPropagation !== null && totalPropagation !== undefined) {
- content_.append('totalPropagation', totalPropagation.toString())
- }
- if (fertilizerIds === null || fertilizerIds === undefined) {
- throw new Error("The parameter 'fertilizerIds' cannot be null.")
- } else {
- fertilizerIds.forEach(item_ => content_.append('fertilizerIds', item_.toString()))
- }
- if (mulchLayerIds === null || mulchLayerIds === undefined) {
- throw new Error("The parameter 'mulchLayerIds' cannot be null.")
- } else {
- mulchLayerIds.forEach(item_ => content_.append('mulchLayerIds', item_.toString()))
- }
- if (seeds === null || seeds === undefined) {
- throw new Error("The parameter 'seeds' cannot be null.")
- } else {
- seeds.forEach(item_ => content_.append('seeds', item_.toString()))
- }
- if (species === null || species === undefined) {
- throw new Error("The parameter 'species' cannot be null.")
- } else {
- species.forEach(item_ => content_.append('species', item_.toString()))
- }
- if (supportedSpecieIds === null || supportedSpecieIds === undefined) {
- throw new Error("The parameter 'supportedSpecieIds' cannot be null.")
- } else {
- supportedSpecieIds.forEach(item_ => content_.append('supportedSpecieIds', item_.toString()))
- }
-
- let options_: RequestInit = {
- body: content_,
- method: 'PATCH',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processUpdate(_response)
- })
- }
-
- protected processUpdate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = BatchDetail.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- /**
- * @return No response body
- */
- delete(batchId: number): Promise {
- let url_ = this.baseUrl + '/analytics/batches/{batchId}/'
- if (batchId === undefined || batchId === null) {
- throw new Error("The parameter 'batchId' must be defined.")
- }
- url_ = url_.replace('{batchId}', encodeURIComponent('' + batchId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'DELETE',
- headers: {},
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDelete(_response)
- })
- }
-
- protected processDelete(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 204) {
- return response.text().then(_responseText => {
- return
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class FertilizerClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- allTypes(): Promise {
- let url_ = this.baseUrl + '/analytics/fertilizers'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAllTypes(_response)
- })
- }
-
- protected processAllTypes(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(FertilizerType.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class MulchLayerClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- allTypes(): Promise {
- let url_ = this.baseUrl + '/analytics/mulch-layers'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAllTypes(_response)
- })
- }
-
- protected processAllTypes(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(MulchLayerType.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class SiteClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- types(): Promise {
- let url_ = this.baseUrl + '/analytics/site-types'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processTypes(_response)
- })
- }
-
- protected processTypes(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(SiteType.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- all(): Promise {
- let url_ = this.baseUrl + '/analytics/sites/'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAll(_response)
- })
- }
-
- protected processAll(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(Site.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- create(
- name?: string | undefined,
- siteType?: number | undefined,
- image?: FileParameter | null | undefined,
- latitude?: string | undefined,
- longitude?: string | undefined,
- description?: string | undefined,
- size?: number | undefined,
- species?: Species3[] | undefined,
- researchPartnership?: boolean | undefined,
- visibleMap?: boolean | undefined,
- ): Promise {
- let url_ = this.baseUrl + '/analytics/sites/'
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = new FormData()
- if (name === null || name === undefined) {
- throw new Error("The parameter 'name' cannot be null.")
- } else {
- content_.append('name', name.toString())
- }
- if (siteType === null || siteType === undefined) {
- throw new Error("The parameter 'siteType' cannot be null.")
- } else {
- content_.append('siteType', siteType.toString())
- }
- if (image !== null && image !== undefined) {
- content_.append('image', image.data, image.fileName ? image.fileName : 'image')
- }
- if (latitude === null || latitude === undefined) {
- throw new Error("The parameter 'latitude' cannot be null.")
- } else {
- content_.append('latitude', latitude.toString())
- }
- if (longitude === null || longitude === undefined) {
- throw new Error("The parameter 'longitude' cannot be null.")
- } else {
- content_.append('longitude', longitude.toString())
- }
- if (description === null || description === undefined) {
- throw new Error("The parameter 'description' cannot be null.")
- } else {
- content_.append('description', description.toString())
- }
- if (size === null || size === undefined) {
- throw new Error("The parameter 'size' cannot be null.")
- } else {
- content_.append('size', size.toString())
- }
- if (species === null || species === undefined) {
- throw new Error("The parameter 'species' cannot be null.")
- } else {
- species.forEach(item_ => content_.append('species', item_.toString()))
- }
- if (researchPartnership === null || researchPartnership === undefined) {
- throw new Error("The parameter 'researchPartnership' cannot be null.")
- } else {
- content_.append('researchPartnership', researchPartnership.toString())
- }
- if (visibleMap === null || visibleMap === undefined) {
- throw new Error("The parameter 'visibleMap' cannot be null.")
- } else {
- content_.append('visibleMap', visibleMap.toString())
- }
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processCreate(_response)
- })
- }
-
- protected processCreate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 201) {
- return response.text().then(_responseText => {
- let result201: any = null
- let resultData201 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result201 = Site.fromJS(resultData201)
- return result201
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- detail(siteId: number): Promise {
- let url_ = this.baseUrl + '/analytics/sites/{siteId}/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDetail(_response)
- })
- }
-
- protected processDetail(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = Site.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- update(
- siteId: number,
- name?: string | undefined,
- siteType?: number | undefined,
- image?: FileParameter | null | undefined,
- latitude?: string | undefined,
- longitude?: string | undefined,
- description?: string | undefined,
- size?: number | undefined,
- species?: Species4[] | undefined,
- researchPartnership?: boolean | undefined,
- visibleMap?: boolean | undefined,
- ): Promise {
- let url_ = this.baseUrl + '/analytics/sites/{siteId}/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = new FormData()
- if (name === null || name === undefined) {
- throw new Error("The parameter 'name' cannot be null.")
- } else {
- content_.append('name', name.toString())
- }
- if (siteType === null || siteType === undefined) {
- throw new Error("The parameter 'siteType' cannot be null.")
- } else {
- content_.append('siteType', siteType.toString())
- }
- if (image !== null && image !== undefined) {
- content_.append('image', image.data, image.fileName ? image.fileName : 'image')
- }
- if (latitude === null || latitude === undefined) {
- throw new Error("The parameter 'latitude' cannot be null.")
- } else {
- content_.append('latitude', latitude.toString())
- }
- if (longitude === null || longitude === undefined) {
- throw new Error("The parameter 'longitude' cannot be null.")
- } else {
- content_.append('longitude', longitude.toString())
- }
- if (description === null || description === undefined) {
- throw new Error("The parameter 'description' cannot be null.")
- } else {
- content_.append('description', description.toString())
- }
- if (size === null || size === undefined) {
- throw new Error("The parameter 'size' cannot be null.")
- } else {
- content_.append('size', size.toString())
- }
- if (species === null || species === undefined) {
- throw new Error("The parameter 'species' cannot be null.")
- } else {
- species.forEach(item_ => content_.append('species', item_.toString()))
- }
- if (researchPartnership === null || researchPartnership === undefined) {
- throw new Error("The parameter 'researchPartnership' cannot be null.")
- } else {
- content_.append('researchPartnership', researchPartnership.toString())
- }
- if (visibleMap === null || visibleMap === undefined) {
- throw new Error("The parameter 'visibleMap' cannot be null.")
- } else {
- content_.append('visibleMap', visibleMap.toString())
- }
-
- let options_: RequestInit = {
- body: content_,
- method: 'PATCH',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processUpdate(_response)
- })
- }
-
- protected processUpdate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = Site.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- /**
- * @return No response body
- */
- delete(siteId: number): Promise {
- let url_ = this.baseUrl + '/analytics/sites/{siteId}/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'DELETE',
- headers: {},
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDelete(_response)
- })
- }
-
- protected processDelete(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 204) {
- return response.text().then(_responseText => {
- return
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- updateAdmins(
- siteId: number,
- body?: PatchedSiteAdminUpdateRequest | undefined,
- ): Promise {
- let url_ = this.baseUrl + '/analytics/sites/{siteId}/admins'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processUpdateAdmins(_response)
- })
- }
-
- protected processUpdateAdmins(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(SiteAdmin.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- /**
- * @return No response body
- */
- follow(siteId: number): Promise {
- let url_ = this.baseUrl + '/analytics/sites/{siteId}/followers/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'POST',
- headers: {},
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processFollow(_response)
- })
- }
-
- protected processFollow(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 201) {
- return response.text().then(_responseText => {
- return
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- /**
- * @return No response body
- */
- unfollow(siteId: number): Promise {
- let url_ = this.baseUrl + '/analytics/sites/{siteId}/followers/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'DELETE',
- headers: {},
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processUnfollow(_response)
- })
- }
-
- protected processUnfollow(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 204) {
- return response.text().then(_responseText => {
- return
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- isFollowing(siteId: number): Promise {
- let url_ = this.baseUrl + '/analytics/sites/{siteId}/followers/current-user/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processIsFollowing(_response)
- })
- }
-
- protected processIsFollowing(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = resultData200 !== undefined ? resultData200 : null
-
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- summary(siteId: number): Promise {
- let url_ = this.baseUrl + '/analytics/sites/{siteId}/summary'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processSummary(_response)
- })
- }
-
- protected processSummary(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = SiteSummaryDetail.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- map(): Promise {
- let url_ = this.baseUrl + '/map/sites/'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processMap(_response)
- })
- }
-
- protected processMap(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(SiteMap.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- social(siteId: number): Promise {
- let url_ = this.baseUrl + '/social/sites/{siteId}/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processSocial(_response)
- })
- }
-
- protected processSocial(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = SiteSocial.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class SummaryClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- all(): Promise {
- let url_ = this.baseUrl + '/analytics/sites/summary'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAll(_response)
- })
- }
-
- protected processAll(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(SiteSummary.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class TreeClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- species(): Promise {
- let url_ = this.baseUrl + '/analytics/tree-species'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processSpecies(_response)
- })
- }
-
- protected processSpecies(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(TreeType.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class SchemaClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- retrieve(format?: Format | undefined, lang?: Lang | undefined): Promise<{ [key: string]: any }> {
- let url_ = this.baseUrl + '/api/schema/?'
- if (format === null) {
- throw new Error("The parameter 'format' cannot be null.")
- } else if (format !== undefined) {
- url_ += 'format=' + encodeURIComponent('' + format) + '&'
- }
- if (lang === null) {
- throw new Error("The parameter 'lang' cannot be null.")
- } else if (lang !== undefined) {
- url_ += 'lang=' + encodeURIComponent('' + lang) + '&'
- }
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/vnd.oai.openapi',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processRetrieve(_response)
- })
- }
-
- protected processRetrieve(response: Response): Promise<{ [key: string]: any }> {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (resultData200) {
- result200 = {} as any
- for (let key in resultData200) {
- if (resultData200.hasOwnProperty(key)) {
- ;( result200)![key] = resultData200[key] !== undefined
- ? resultData200[key]
- : null
- }
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve<{ [key: string]: any }>(null as any)
- }
-}
-
-export class AuthenticationClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- login(body: LoginUser): Promise {
- let url_ = this.baseUrl + '/auth/login/'
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processLogin(_response)
- })
- }
-
- protected processLogin(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = UserToken.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- register(body: RegisterUser): Promise {
- let url_ = this.baseUrl + '/auth/register/'
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processRegister(_response)
- })
- }
-
- protected processRegister(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 201) {
- return response.text().then(_responseText => {
- let result201: any = null
- let resultData201 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result201 = UserToken.fromJS(resultData201)
- return result201
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class TokenClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- create(body: TokenObtainPair): Promise {
- let url_ = this.baseUrl + '/auth/token/'
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processCreate(_response)
- })
- }
-
- protected processCreate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = TokenObtainPair.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class RefreshClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- create(body: TokenRefresh): Promise {
- let url_ = this.baseUrl + '/auth/token/refresh/'
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processCreate(_response)
- })
- }
-
- protected processCreate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = TokenRefresh.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class ContactClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- update(contactId: number, body?: PatchedContact | undefined): Promise {
- let url_ = this.baseUrl + '/social/contacts/{contactId}/'
- if (contactId === undefined || contactId === null) {
- throw new Error("The parameter 'contactId' must be defined.")
- }
- url_ = url_.replace('{contactId}', encodeURIComponent('' + contactId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processUpdate(_response)
- })
- }
-
- protected processUpdate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = Contact.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class PostClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- all(page: number, size: number, siteId?: number[] | undefined): Promise {
- let url_ = this.baseUrl + '/social/posts/?'
- if (page === undefined || page === null) {
- throw new Error("The parameter 'page' must be defined and cannot be null.")
- } else {
- url_ += 'page=' + encodeURIComponent('' + page) + '&'
- }
- if (size === undefined || size === null) {
- throw new Error("The parameter 'size' must be defined and cannot be null.")
- } else {
- url_ += 'size=' + encodeURIComponent('' + size) + '&'
- }
- if (siteId === null) {
- throw new Error("The parameter 'siteId' cannot be null.")
- } else if (siteId !== undefined) {
- siteId && siteId.forEach(item => {
- url_ += 'siteId=' + encodeURIComponent('' + item) + '&'
- })
- }
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAll(_response)
- })
- }
-
- protected processAll(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = PostPagination.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- create(
- site?: number | undefined,
- body?: string | undefined,
- media?: FileParameter[] | undefined,
- ): Promise {
- let url_ = this.baseUrl + '/social/posts/'
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = new FormData()
- if (site === null || site === undefined) {
- throw new Error("The parameter 'site' cannot be null.")
- } else {
- content_.append('site', site.toString())
- }
- if (body === null || body === undefined) {
- throw new Error("The parameter 'body' cannot be null.")
- } else {
- content_.append('body', body.toString())
- }
- if (media === null || media === undefined) {
- throw new Error("The parameter 'media' cannot be null.")
- } else {
- media.forEach(item_ =>
- content_.append('media', item_.data, item_.fileName ? item_.fileName : 'media')
- )
- }
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processCreate(_response)
- })
- }
-
- protected processCreate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 201) {
- return response.text().then(_responseText => {
- let result201: any = null
- let resultData201 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result201 = Post.fromJS(resultData201)
- return result201
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- detail(postId: number): Promise {
- let url_ = this.baseUrl + '/social/posts/{postId}/'
- if (postId === undefined || postId === null) {
- throw new Error("The parameter 'postId' must be defined.")
- }
- url_ = url_.replace('{postId}', encodeURIComponent('' + postId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDetail(_response)
- })
- }
-
- protected processDetail(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = Post.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- /**
- * @return No response body
- */
- delete(postId: number): Promise {
- let url_ = this.baseUrl + '/social/posts/{postId}/'
- if (postId === undefined || postId === null) {
- throw new Error("The parameter 'postId' must be defined.")
- }
- url_ = url_.replace('{postId}', encodeURIComponent('' + postId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'DELETE',
- headers: {},
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDelete(_response)
- })
- }
-
- protected processDelete(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 204) {
- return response.text().then(_responseText => {
- return
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class CommentClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- all(postId: number): Promise {
- let url_ = this.baseUrl + '/social/posts/{postId}/comments/'
- if (postId === undefined || postId === null) {
- throw new Error("The parameter 'postId' must be defined.")
- }
- url_ = url_.replace('{postId}', encodeURIComponent('' + postId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAll(_response)
- })
- }
-
- protected processAll(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(Comment.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- create(postId: number, body: CreateComment): Promise {
- let url_ = this.baseUrl + '/social/posts/{postId}/comments/'
- if (postId === undefined || postId === null) {
- throw new Error("The parameter 'postId' must be defined.")
- }
- url_ = url_.replace('{postId}', encodeURIComponent('' + postId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processCreate(_response)
- })
- }
-
- protected processCreate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 201) {
- return response.text().then(_responseText => {
- let result201: any = null
- let resultData201 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result201 = Comment.fromJS(resultData201)
- return result201
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- /**
- * @return No response body
- */
- delete(commentId: number, postId: number): Promise {
- let url_ = this.baseUrl + '/social/posts/{postId}/comments/{commentId}/'
- if (commentId === undefined || commentId === null) {
- throw new Error("The parameter 'commentId' must be defined.")
- }
- url_ = url_.replace('{commentId}', encodeURIComponent('' + commentId))
- if (postId === undefined || postId === null) {
- throw new Error("The parameter 'postId' must be defined.")
- }
- url_ = url_.replace('{postId}', encodeURIComponent('' + postId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'DELETE',
- headers: {},
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDelete(_response)
- })
- }
-
- protected processDelete(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 204) {
- return response.text().then(_responseText => {
- return
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class LikeClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- likePost(postId: number, body?: { [key: string]: any } | undefined): Promise {
- let url_ = this.baseUrl + '/social/posts/{postId}/likes/'
- if (postId === undefined || postId === null) {
- throw new Error("The parameter 'postId' must be defined.")
- }
- url_ = url_.replace('{postId}', encodeURIComponent('' + postId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processLikePost(_response)
- })
- }
-
- protected processLikePost(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 201) {
- return response.text().then(_responseText => {
- let result201: any = null
- let resultData201 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result201 = Like.fromJS(resultData201)
- return result201
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- delete(postId: number): Promise {
- let url_ = this.baseUrl + '/social/posts/{postId}/likes/'
- if (postId === undefined || postId === null) {
- throw new Error("The parameter 'postId' must be defined.")
- }
- url_ = url_.replace('{postId}', encodeURIComponent('' + postId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'DELETE',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDelete(_response)
- })
- }
-
- protected processDelete(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 201) {
- return response.text().then(_responseText => {
- let result201: any = null
- let resultData201 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result201 = Like.fromJS(resultData201)
- return result201
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class AnnouncementClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- update(siteId: number, body?: PatchedAnnouncement | undefined): Promise {
- let url_ = this.baseUrl + '/social/sites/{siteId}/announcements/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processUpdate(_response)
- })
- }
-
- protected processUpdate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = Announcement.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class SocialClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- updatePublicStatus(
- siteId: number,
- body?: PatchedUpdateSitePublicStatus | undefined,
- ): Promise {
- let url_ = this.baseUrl + '/social/sites/{siteId}/public-status'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processUpdatePublicStatus(_response)
- })
- }
-
- protected processUpdatePublicStatus(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = UpdateSitePublicStatus.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class WidgetClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- create(siteId: number, body?: Widget | undefined): Promise {
- let url_ = this.baseUrl + '/social/sites/{siteId}/widgets/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processCreate(_response)
- })
- }
-
- protected processCreate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 201) {
- return response.text().then(_responseText => {
- let result201: any = null
- let resultData201 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result201 = Widget.fromJS(resultData201)
- return result201
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- update(siteId: number, widgetId: number, body?: PatchedWidget | undefined): Promise {
- let url_ = this.baseUrl + '/social/sites/{siteId}/widgets/{widgetId}/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- if (widgetId === undefined || widgetId === null) {
- throw new Error("The parameter 'widgetId' must be defined.")
- }
- url_ = url_.replace('{widgetId}', encodeURIComponent('' + widgetId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processUpdate(_response)
- })
- }
-
- protected processUpdate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = Widget.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- /**
- * @return No response body
- */
- delete(siteId: number, widgetId: number): Promise {
- let url_ = this.baseUrl + '/social/sites/{siteId}/widgets/{widgetId}/'
- if (siteId === undefined || siteId === null) {
- throw new Error("The parameter 'siteId' must be defined.")
- }
- url_ = url_.replace('{siteId}', encodeURIComponent('' + siteId))
- if (widgetId === undefined || widgetId === null) {
- throw new Error("The parameter 'widgetId' must be defined.")
- }
- url_ = url_.replace('{widgetId}', encodeURIComponent('' + widgetId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'DELETE',
- headers: {},
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDelete(_response)
- })
- }
-
- protected processDelete(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 204) {
- return response.text().then(_responseText => {
- return
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class UserInvitationClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- create(body: CreateUserInvitation): Promise {
- let url_ = this.baseUrl + '/user-invitations/'
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processCreate(_response)
- })
- }
-
- protected processCreate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = UserInvitation.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- detail(code: string): Promise {
- let url_ = this.baseUrl + '/user-invitations/{code}'
- if (code === undefined || code === null) {
- throw new Error("The parameter 'code' must be defined.")
- }
- url_ = url_.replace('{code}', encodeURIComponent('' + code))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDetail(_response)
- })
- }
-
- protected processDetail(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = UserInvitation.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class UserClient {
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }
- private baseUrl: string
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined
-
- constructor(
- baseUrl?: string,
- http?: { fetch(url: RequestInfo, init?: RequestInit): Promise },
- ) {
- this.http = http ? http : window as any
- this.baseUrl = baseUrl ?? ''
- }
-
- all(): Promise {
- let url_ = this.baseUrl + '/users/'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAll(_response)
- })
- }
-
- protected processAll(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(User.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- detail(userId: number): Promise {
- let url_ = this.baseUrl + '/users/{userId}/'
- if (userId === undefined || userId === null) {
- throw new Error("The parameter 'userId' must be defined.")
- }
- url_ = url_.replace('{userId}', encodeURIComponent('' + userId))
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processDetail(_response)
- })
- }
-
- protected processDetail(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = User.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- update(userId: number, body?: PatchedUpdateUser | undefined): Promise {
- let url_ = this.baseUrl + '/users/{userId}/'
- if (userId === undefined || userId === null) {
- throw new Error("The parameter 'userId' must be defined.")
- }
- url_ = url_.replace('{userId}', encodeURIComponent('' + userId))
- url_ = url_.replace(/[?&]$/, '')
-
- const content_ = JSON.stringify(body)
-
- let options_: RequestInit = {
- body: content_,
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processUpdate(_response)
- })
- }
-
- protected processUpdate(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = User.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- current(): Promise {
- let url_ = this.baseUrl + '/users/current_user/'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processCurrent(_response)
- })
- }
-
- protected processCurrent(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- result200 = User.fromJS(resultData200)
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-
- allForestStewards(): Promise {
- let url_ = this.baseUrl + '/users/forest-stewards'
- url_ = url_.replace(/[?&]$/, '')
-
- let options_: RequestInit = {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- },
- }
-
- return this.http.fetch(url_, options_).then((_response: Response) => {
- return this.processAllForestStewards(_response)
- })
- }
-
- protected processAllForestStewards(response: Response): Promise {
- const status = response.status
- let _headers: any = {}
- if (response.headers && response.headers.forEach) {
- response.headers.forEach((v: any, k: any) => _headers[k] = v)
- }
- if (status === 200) {
- return response.text().then(_responseText => {
- let result200: any = null
- let resultData200 = _responseText === ''
- ? null
- : JSON.parse(_responseText, this.jsonParseReviver)
- if (Array.isArray(resultData200)) {
- result200 = [] as any
- for (let item of resultData200) {
- result200!.push(User.fromJS(item))
- }
- } else {
- result200 = null
- }
- return result200
- })
- } else if (status !== 200 && status !== 204) {
- return response.text().then(_responseText => {
- return throwException(
- 'An unexpected server error occurred.',
- status,
- _responseText,
- _headers,
- )
- })
- }
- return Promise.resolve(null as any)
- }
-}
-
-export class AdminUserSites implements IAdminUserSites {
- readonly id!: number
- /** Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only. */
- username!: string
- email!: string
- readonly sites!: SiteName[];
-
- [key: string]: any
-
- constructor(data?: IAdminUserSites) {
- if (data) {
- for (var property in data) {
- if (data.hasOwnProperty(property)) {
- ;( this)[property] = ( data)[property]
- }
- }
- }
- if (!data) {
- this.sites = []
- }
- }
-
- init(_data?: any) {
- if (_data) {
- for (var property in _data) {
- if (_data.hasOwnProperty(property)) {
- this[property] = _data[property]
- }
- }
- ;( this).id = _data['id']
- this.username = _data['username']
- this.email = _data['email']
- if (Array.isArray(_data['sites'])) {
- ;( this).sites = [] as any
- for (let item of _data['sites']) {
- ;( this).sites!.push(SiteName.fromJS(item))
- }
- }
- }
- }
-
- static fromJS(data: any): AdminUserSites {
- data = typeof data === 'object' ? data : {}
- let result = new AdminUserSites()
- result.init(data)
- return result
- }
-
- toJSON(data?: any) {
- data = typeof data === 'object' ? data : {}
- for (var property in this) {
- if (this.hasOwnProperty(property)) {
- data[property] = this[property]
- }
- }
- data['id'] = this.id
- data['username'] = this.username
- data['email'] = this.email
- if (Array.isArray(this.sites)) {
- data['sites'] = []
- for (let item of this.sites) {
- data['sites'].push(item.toJSON())
- }
- }
- return data
- }
-}
-
-export interface IAdminUserSites {
- id: number
- /** Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only. */
- username: string
- email: string
- sites: SiteName[]
-
- [key: string]: any
-}
-
-export class Announcement implements IAnnouncement {
- readonly id!: number
- body?: string | undefined
- link?: string | undefined;
-
- [key: string]: any
-
- constructor(data?: IAnnouncement) {
- if (data) {
- for (var property in data) {
- if (data.hasOwnProperty(property)) {
- ;( this)[property] = ( data)[property]
- }
- }
- }
- }
-
- init(_data?: any) {
- if (_data) {
- for (var property in _data) {
- if (_data.hasOwnProperty(property)) {
- this[property] = _data[property]
- }
- }
- ;( this).id = _data['id']
- this.body = _data['body']
- this.link = _data['link']
- }
- }
-
- static fromJS(data: any): Announcement {
- data = typeof data === 'object' ? data : {}
- let result = new Announcement()
- result.init(data)
- return result
- }
-
- toJSON(data?: any) {
- data = typeof data === 'object' ? data : {}
- for (var property in this) {
- if (this.hasOwnProperty(property)) {
- data[property] = this[property]
- }
- }
- data['id'] = this.id
- data['body'] = this.body
- data['link'] = this.link
- return data
- }
-}
-
-export interface IAnnouncement {
- id: number
- body?: string | undefined
- link?: string | undefined
-
- [key: string]: any
-}
-
-export class Asset implements IAsset {
- readonly id!: number
- asset!: string;
-
- [key: string]: any
-
- constructor(data?: IAsset) {
- if (data) {
- for (var property in data) {
- if (data.hasOwnProperty(property)) {
- ;( this)[property] = ( data)[property]
- }
- }
- }
- }
-
- init(_data?: any) {
- if (_data) {
- for (var property in _data) {
- if (_data.hasOwnProperty(property)) {
- this[property] = _data[property]
- }
- }
- ;( this).id = _data['id']
- this.asset = _data['asset']
- }
- }
-
- static fromJS(data: any): Asset {
- data = typeof data === 'object' ? data : {}
- let result = new Asset()
- result.init(data)
- return result
- }
-
- toJSON(data?: any) {
- data = typeof data === 'object' ? data : {}
- for (var property in this) {
- if (this.hasOwnProperty(property)) {
- data[property] = this[property]
- }
- }
- data['id'] = this.id
- data['asset'] = this.asset
- return data
- }
-}
-
-export interface IAsset {
- id: number
- asset: string
-
- [key: string]: any
-}
-
-export class BatchDetail implements IBatchDetail {
- readonly id!: number
- readonly fertilizers!: FertilizerType[]
- readonly mulchLayers!: MulchLayerType[]
- readonly supportedSpecies!: TreeType[]
- readonly seeds!: BatchSeed[]
- readonly totalNumberSeeds!: number
- readonly species!: BatchSpecies[]
- readonly plantCount!: number
- readonly sponsor!: BatchSponsor
- image?: Asset
- readonly createdAt!: Date | undefined
- readonly updatedAt!: Date | undefined
- name?: string | undefined
- size?: number | undefined
- soilCondition?: string | undefined
- survivedCount?: number | undefined
- replaceCount?: number | undefined
- totalPropagation?: number | undefined
- site!: number;
-
- [key: string]: any
-
- constructor(data?: IBatchDetail) {
- if (data) {
- for (var property in data) {
- if (data.hasOwnProperty(property)) {
- ;( this)[property] = ( data)[property]
- }
- }
- }
- if (!data) {
- this.fertilizers = []
- this.mulchLayers = []
- this.supportedSpecies = []
- this.seeds = []
- this.species = []
- this.sponsor = new BatchSponsor()
- }
- }
-
- init(_data?: any) {
- if (_data) {
- for (var property in _data) {
- if (_data.hasOwnProperty(property)) {
- this[property] = _data[property]
- }
- }
- ;( this).id = _data['id']
- if (Array.isArray(_data['fertilizers'])) {
- ;( this).fertilizers = [] as any
- for (let item of _data['fertilizers']) {
- ;( this).fertilizers!.push(FertilizerType.fromJS(item))
- }
- }
- if (Array.isArray(_data['mulchLayers'])) {
- ;( this).mulchLayers = [] as any
- for (let item of _data['mulchLayers']) {
- ;( this).mulchLayers!.push(MulchLayerType.fromJS(item))
- }
- }
- if (Array.isArray(_data['supportedSpecies'])) {
- ;( this).supportedSpecies = [] as any
- for (let item of _data['supportedSpecies']) {
- ;( this).supportedSpecies!.push(TreeType.fromJS(item))
- }
- }
- if (Array.isArray(_data['seeds'])) {
- ;( this).seeds = [] as any
- for (let item of _data['seeds']) {
- ;( this).seeds!.push(BatchSeed.fromJS(item))
- }
- }
- ;( this).totalNumberSeeds = _data['totalNumberSeeds']
- if (Array.isArray(_data['species'])) {
- ;( this).species = [] as any
- for (let item of _data['species']) {
- ;( this).species!.push(BatchSpecies.fromJS(item))
- }
- }
- ;( this).plantCount = _data['plantCount']
- ;( this).sponsor = _data['sponsor']
- ? BatchSponsor.fromJS(_data['sponsor'])
- : new BatchSponsor()
- this.image = _data['image'] ? Asset.fromJS(_data['image']) : undefined
- ;( this).createdAt = _data['createdAt']
- ? new Date(_data['createdAt'].toString())
- : undefined
- ;( this).updatedAt = _data['updatedAt']
- ? new Date(_data['updatedAt'].toString())
- : undefined
- this.name = _data['name']
- this.size = _data['size']
- this.soilCondition = _data['soilCondition']
- this.survivedCount = _data['survivedCount']
- this.replaceCount = _data['replaceCount']
- this.totalPropagation = _data['totalPropagation']
- this.site = _data['site']
- }
- }
-
- static fromJS(data: any): BatchDetail {
- data = typeof data === 'object' ? data : {}
- let result = new BatchDetail()
- result.init(data)
- return result
- }
-
- toJSON(data?: any) {
- data = typeof data === 'object' ? data : {}
- for (var property in this) {
- if (this.hasOwnProperty(property)) {
- data[property] = this[property]
- }
- }
- data['id'] = this.id
- if (Array.isArray(this.fertilizers)) {
- data['fertilizers'] = []
- for (let item of this.fertilizers) {
- data['fertilizers'].push(item.toJSON())
- }
- }
- if (Array.isArray(this.mulchLayers)) {
- data['mulchLayers'] = []
- for (let item of this.mulchLayers) {
- data['mulchLayers'].push(item.toJSON())
- }
- }
- if (Array.isArray(this.supportedSpecies)) {
- data['supportedSpecies'] = []
- for (let item of this.supportedSpecies) {
- data['supportedSpecies'].push(item.toJSON())
- }
- }
- if (Array.isArray(this.seeds)) {
- data['seeds'] = []
- for (let item of this.seeds) {
- data['seeds'].push(item.toJSON())
- }
- }
- data['totalNumberSeeds'] = this.totalNumberSeeds
- if (Array.isArray(this.species)) {
- data['species'] = []
- for (let item of this.species) {
- data['species'].push(item.toJSON())
- }
- }
- data['plantCount'] = this.plantCount
- data['sponsor'] = this.sponsor ? this.sponsor.toJSON() : undefined
- data['image'] = this.image ? this.image.toJSON() : undefined
- data['createdAt'] = this.createdAt ? this.createdAt.toISOString() : undefined
- data['updatedAt'] = this.updatedAt ? this.updatedAt.toISOString() : undefined
- data['name'] = this.name
- data['size'] = this.size
- data['soilCondition'] = this.soilCondition
- data['survivedCount'] = this.survivedCount
- data['replaceCount'] = this.replaceCount
- data['totalPropagation'] = this.totalPropagation
- data['site'] = this.site
- return data
- }
-}
-
-export interface IBatchDetail {
- id: number
- fertilizers: FertilizerType[]
- mulchLayers: MulchLayerType[]
- supportedSpecies: TreeType[]
- seeds: BatchSeed[]
- totalNumberSeeds: number
- species: BatchSpecies[]
- plantCount: number
- sponsor: BatchSponsor
- image?: Asset
- createdAt: Date | undefined
- updatedAt: Date | undefined
- name?: string | undefined
- size?: number | undefined
- soilCondition?: string | undefined
- survivedCount?: number | undefined
- replaceCount?: number | undefined
- totalPropagation?: number | undefined
- site: number
-
- [key: string]: any
-}
-
-export class BatchSeed implements IBatchSeed {
- readonly id!: number
- quantity!: number
- readonly treeType!: TreeType;
-
- [key: string]: any
-
- constructor(data?: IBatchSeed) {
- if (data) {
- for (var property in data) {
- if (data.hasOwnProperty(property)) {
- ;( this)[property] = ( data)[property]
- }
- }
- }
- if (!data) {
- this.treeType = new TreeType()
- }
- }
-
- init(_data?: any) {
- if (_data) {
- for (var property in _data) {
- if (_data.hasOwnProperty(property)) {
- this[property] = _data[property]
- }
- }
- ;( this).id = _data['id']
- this.quantity = _data['quantity']
- ;( this).treeType = _data['treeType']
- ? TreeType.fromJS(_data['treeType'])
- : new TreeType()
- }
- }
-
- static fromJS(data: any): BatchSeed {
- data = typeof data === 'object' ? data : {}
- let result = new BatchSeed()
- result.init(data)
- return result
- }
-
- toJSON(data?: any) {
- data = typeof data === 'object' ? data : {}
- for (var property in this) {
- if (this.hasOwnProperty(property)) {
- data[property] = this[property]
- }
- }
- data['id'] = this.id
- data['quantity'] = this.quantity
- data['treeType'] = this.treeType ? this.treeType.toJSON() : undefined
- return data
- }
-}
-
-export interface IBatchSeed {
- id: number
- quantity: number
- treeType: TreeType
-
- [key: string]: any
-}
-
-export class BatchSpecies implements IBatchSpecies {
- readonly id!: number
- quantity!: number
- readonly treeType!: TreeType;
-
- [key: string]: any
-
- constructor(data?: IBatchSpecies) {
- if (data) {
- for (var property in data) {
- if (data.hasOwnProperty(property)) {
- ;( this)[property] = ( data)[property]
- }
- }
- }
- if (!data) {
- this.treeType = new TreeType()
- }
- }
-
- init(_data?: any) {
- if (_data) {
- for (var property in _data) {
- if (_data.hasOwnProperty(property)) {
- this[property] = _data[property]
- }
- }
- ;( this).id = _data['id']
- this.quantity = _data['quantity']
- ;( this).treeType = _data['treeType']
- ? TreeType.fromJS(_data['treeType'])
- : new TreeType()
- }
- }
-
- static fromJS(data: any): BatchSpecies {
- data = typeof data === 'object' ? data : {}
- let result = new BatchSpecies()
- result.init(data)
- return result
- }
-
- toJSON(data?: any) {
- data = typeof data === 'object' ? data : {}
- for (var property in this) {
- if (this.hasOwnProperty(property)) {
- data[property] = this[property]
- }
- }
- data['id'] = this.id
- data['quantity'] = this.quantity
- data['treeType'] = this.treeType ? this.treeType.toJSON() : undefined
- return data
- }
-}
-
-export interface IBatchSpecies {
- id: number
- quantity: number
- treeType: TreeType
-
- [key: string]: any
-}
-
-export class BatchSponsor implements IBatchSponsor {
- readonly id!: number
- logo!: Asset
- name!: string
- url!: string;
-
- [key: string]: any
-
- constructor(data?: IBatchSponsor) {
- if (data) {
- for (var property in data) {
- if (data.hasOwnProperty(property)) {
- ;( this)[property] = ( data)[property]
- }
- }
- }
- if (!data) {
- this.logo = new Asset()
- }
- }
-
- init(_data?: any) {
- if (_data) {
- for (var property in _data) {
- if (_data.hasOwnProperty(property)) {
- this[property] = _data[property]
- }
- }
- ;( this).id = _data['id']
- this.logo = _data['logo'] ? Asset.fromJS(_data['logo']) : new Asset()
- this.name = _data['name']
- this.url = _data['url']
- }
- }
-
- static fromJS(data: any): BatchSponsor {
- data = typeof data === 'object' ? data : {}
- let result = new BatchSponsor()
- result.init(data)
- return result
- }
-
- toJSON(data?: any) {
- data = typeof data === 'object' ? data : {}
- for (var property in this) {
- if (this.hasOwnProperty(property)) {
- data[property] = this[property]
- }
- }
- data['id'] = this.id
- data['logo'] = this.logo ? this.logo.toJSON() : undefined
- data['name'] = this.name
- data['url'] = this.url
- return data
- }
-}
-
-export interface IBatchSponsor {
- id: number
- logo: Asset
- name: string
- url: string
-
- [key: string]: any
-}
-
-export class ChangePassword implements IChangePassword {
- currentPassword!: string
- newPassword!: string
- newPasswordConfirmation!: string;
-
- [key: string]: any
-
- constructor(data?: IChangePassword) {
- if (data) {
- for (var property in data) {
- if (data.hasOwnProperty(property)) {
- ;( this)[property] = ( data)[property]
- }
- }
- }
- }
-
- init(_data?: any) {
- if (_data) {
- for (var property in _data) {
- if (_data.hasOwnProperty(property)) {
- this[property] = _data[property]
- }
- }
- this.currentPassword = _data['currentPassword']
- this.newPassword = _data['newPassword']
- this.newPasswordConfirmation = _data['newPasswordConfirmation']
- }
- }
-
- static fromJS(data: any): ChangePassword {
- data = typeof data === 'object' ? data : {}
- let result = new ChangePassword()
- result.init(data)
- return result
- }
-
- toJSON(data?: any) {
- data = typeof data === 'object' ? data : {}
- for (var property in this) {
- if (this.hasOwnProperty(property)) {
- data[property] = this[property]
- }
- }
- data['currentPassword'] = this.currentPassword
- data['newPassword'] = this.newPassword
- data['newPasswordConfirmation'] = this.newPasswordConfirmation
- return data
- }
-}
-
-export interface IChangePassword {
- currentPassword: string
- newPassword: string
- newPasswordConfirmation: string
-
- [key: string]: any
-}
-
-export class Comment implements IComment {
- readonly id!: number
- body!: string
- readonly authorId!: number
- readonly authorUsername!: string
- readonly createdAt!: Date;
-
- [key: string]: any
-
- constructor(data?: IComment) {
- if (data) {
- for (var property in data) {
- if (data.hasOwnProperty(property)) {
- ;( this)[property] = (