Skip to content

Commit

Permalink
Merge pull request #153 from badsyntax/api-usage
Browse files Browse the repository at this point in the history
Use api for contact page
  • Loading branch information
badsyntax authored Oct 17, 2021
2 parents cad301a + 56fbdeb commit aa93d90
Show file tree
Hide file tree
Showing 14 changed files with 453 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/features/api/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ProjectspageApi,
} from './strapi';
import { AboutpageApi } from './strapi/apis/AboutpageApi';
import { ContactpageApi } from './strapi/apis/ContactpageApi';

const configParams: ConfigurationParameters = {
basePath: process.env.STRAPI_ENDPOINT,
Expand All @@ -22,6 +23,7 @@ export const apiClient = {
projectApi: new ProjectApi(apiConfig),
aboutpageApi: new AboutpageApi(apiConfig),
projectspageApi: new ProjectspageApi(apiConfig),
contactPageApi: new ContactpageApi(apiConfig),
};

export type ApiClient = typeof apiClient;
Expand Down
3 changes: 3 additions & 0 deletions src/features/api/strapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apis/AboutpageApi.ts
apis/ArticleApi.ts
apis/CategoryApi.ts
apis/CommentApi.ts
apis/ContactpageApi.ts
apis/GlobalApi.ts
apis/HomepageApi.ts
apis/ProjectApi.ts
Expand All @@ -15,6 +16,7 @@ models/AboutpageSeo.ts
models/Article.ts
models/Category.ts
models/Comment.ts
models/Contactpage.ts
models/Global.ts
models/Homepage.ts
models/HomepageHero.ts
Expand All @@ -24,6 +26,7 @@ models/NewArticle.ts
models/NewArticleComment.ts
models/NewCategory.ts
models/NewComment.ts
models/NewContactpage.ts
models/NewGlobal.ts
models/NewHomepage.ts
models/NewProject.ts
Expand Down
207 changes: 207 additions & 0 deletions src/features/api/strapi/apis/ContactpageApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
/* tslint:disable */
/* eslint-disable */
/**
* DOCUMENTATION
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import * as runtime from '../runtime';
import {
Contactpage,
ContactpageFromJSON,
ContactpageToJSON,
NewContactpage,
NewContactpageFromJSON,
NewContactpageToJSON,
} from '../models';

export interface ContactpageGetRequest {
limit?: number;
sort?: string;
start?: number;
ne?: string;
lt?: string;
lte?: string;
gt?: string;
gte?: string;
contains?: string;
containss?: string;
_in?: Array<string>;
nin?: Array<string>;
}

export interface ContactpagePutRequest {
newContactpage: NewContactpage;
}

/**
*
*/
export class ContactpageApi extends runtime.BaseAPI {

/**
* Delete a single contactpage record
*/
async contactpageDeleteRaw(initOverrides?: RequestInit): Promise<runtime.ApiResponse<number>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearerAuth", []);

if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/contactpage`,
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.TextApiResponse(response) as any;
}

/**
* Delete a single contactpage record
*/
async contactpageDelete(initOverrides?: RequestInit): Promise<number> {
const response = await this.contactpageDeleteRaw(initOverrides);
return await response.value();
}

/**
* Find all the contactpage\'s records
*/
async contactpageGetRaw(requestParameters: ContactpageGetRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Contactpage>> {
const queryParameters: any = {};

if (requestParameters.limit !== undefined) {
queryParameters['_limit'] = requestParameters.limit;
}

if (requestParameters.sort !== undefined) {
queryParameters['_sort'] = requestParameters.sort;
}

if (requestParameters.start !== undefined) {
queryParameters['_start'] = requestParameters.start;
}

if (requestParameters.ne !== undefined) {
queryParameters['_ne'] = requestParameters.ne;
}

if (requestParameters.lt !== undefined) {
queryParameters['_lt'] = requestParameters.lt;
}

if (requestParameters.lte !== undefined) {
queryParameters['_lte'] = requestParameters.lte;
}

if (requestParameters.gt !== undefined) {
queryParameters['_gt'] = requestParameters.gt;
}

if (requestParameters.gte !== undefined) {
queryParameters['_gte'] = requestParameters.gte;
}

if (requestParameters.contains !== undefined) {
queryParameters['_contains'] = requestParameters.contains;
}

if (requestParameters.containss !== undefined) {
queryParameters['_containss'] = requestParameters.containss;
}

if (requestParameters._in) {
queryParameters['_in'] = requestParameters._in;
}

if (requestParameters.nin) {
queryParameters['_nin'] = requestParameters.nin;
}

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearerAuth", []);

if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/contactpage`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ContactpageFromJSON(jsonValue));
}

/**
* Find all the contactpage\'s records
*/
async contactpageGet(requestParameters: ContactpageGetRequest, initOverrides?: RequestInit): Promise<Contactpage> {
const response = await this.contactpageGetRaw(requestParameters, initOverrides);
return await response.value();
}

/**
* Update a single contactpage record
*/
async contactpagePutRaw(requestParameters: ContactpagePutRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Contactpage>> {
if (requestParameters.newContactpage === null || requestParameters.newContactpage === undefined) {
throw new runtime.RequiredError('newContactpage','Required parameter requestParameters.newContactpage was null or undefined when calling contactpagePut.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearerAuth", []);

if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/contactpage`,
method: 'PUT',
headers: headerParameters,
query: queryParameters,
body: NewContactpageToJSON(requestParameters.newContactpage),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ContactpageFromJSON(jsonValue));
}

/**
* Update a single contactpage record
*/
async contactpagePut(requestParameters: ContactpagePutRequest, initOverrides?: RequestInit): Promise<Contactpage> {
const response = await this.contactpagePutRaw(requestParameters, initOverrides);
return await response.value();
}

}
1 change: 1 addition & 0 deletions src/features/api/strapi/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './AboutpageApi';
export * from './ArticleApi';
export * from './CategoryApi';
export * from './CommentApi';
export * from './ContactpageApi';
export * from './GlobalApi';
export * from './HomepageApi';
export * from './ProjectApi';
Expand Down
88 changes: 88 additions & 0 deletions src/features/api/strapi/models/Contactpage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* tslint:disable */
/* eslint-disable */
/**
* DOCUMENTATION
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
import {
AboutpageSeo,
AboutpageSeoFromJSON,
AboutpageSeoFromJSONTyped,
AboutpageSeoToJSON,
} from './';

/**
*
* @export
* @interface Contactpage
*/
export interface Contactpage {
/**
*
* @type {string}
* @memberof Contactpage
*/
id: string;
/**
*
* @type {AboutpageSeo}
* @memberof Contactpage
*/
seo?: AboutpageSeo;
/**
*
* @type {string}
* @memberof Contactpage
*/
body?: string;
/**
*
* @type {Date}
* @memberof Contactpage
*/
publishedAt?: Date;
}

export function ContactpageFromJSON(json: any): Contactpage {
return ContactpageFromJSONTyped(json, false);
}

export function ContactpageFromJSONTyped(json: any, ignoreDiscriminator: boolean): Contactpage {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'id': json['id'],
'seo': !exists(json, 'seo') ? undefined : AboutpageSeoFromJSON(json['seo']),
'body': !exists(json, 'body') ? undefined : json['body'],
'publishedAt': !exists(json, 'published_at') ? undefined : (new Date(json['published_at'])),
};
}

export function ContactpageToJSON(value?: Contactpage | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

'id': value.id,
'seo': AboutpageSeoToJSON(value.seo),
'body': value.body,
'published_at': value.publishedAt === undefined ? undefined : (value.publishedAt.toISOString()),
};
}


Loading

0 comments on commit aa93d90

Please sign in to comment.