From ef37fa6390b2158072134bc3d1b18c63a411b959 Mon Sep 17 00:00:00 2001 From: anpigon Date: Tue, 30 Aug 2022 20:30:01 +0900 Subject: [PATCH] refactor: clean up the response model file --- src/apis/models/google_books_response.ts | 78 ++++-------------------- src/apis/models/naver_books_response.ts | 9 --- 2 files changed, 12 insertions(+), 75 deletions(-) diff --git a/src/apis/models/google_books_response.ts b/src/apis/models/google_books_response.ts index d316840..c02cbbb 100644 --- a/src/apis/models/google_books_response.ts +++ b/src/apis/models/google_books_response.ts @@ -1,12 +1,3 @@ -// To parse this data: -// -// import { Convert, GoogleBooks } from "./file"; -// -// const googleBooks = Convert.toGoogleBooks(json); -// -// These functions will throw an error if the JSON doesn't -// match the expected interface, even if the JSON is valid. - /* eslint-disable @typescript-eslint/no-explicit-any */ export interface GoogleBooksResponse { kind: string; @@ -15,7 +6,7 @@ export interface GoogleBooksResponse { } export interface Item { - kind: Kind; + kind: string; id: string; etag: string; selfLink: string; @@ -26,48 +17,26 @@ export interface Item { } export interface AccessInfo { - country: Country; - viewability: Viewability; + country: string; + viewability: string; embeddable: boolean; publicDomain: boolean; - textToSpeechPermission: TextToSpeechPermission; + textToSpeechPermission: string; epub: Epub; pdf: Epub; webReaderLink: string; - accessViewStatus: AccessViewStatus; + accessViewStatus: string; quoteSharingAllowed: boolean; } -export enum AccessViewStatus { - None = 'NONE', - Sample = 'SAMPLE', -} - -export enum Country { - Kr = 'KR', -} - export interface Epub { isAvailable: boolean; acsTokenLink?: string; } -export enum TextToSpeechPermission { - Allowed = 'ALLOWED', -} - -export enum Viewability { - NoPages = 'NO_PAGES', - Partial = 'PARTIAL', -} - -export enum Kind { - BooksVolume = 'books#volume', -} - export interface SaleInfo { - country: Country; - saleability: Saleability; + country: string; + saleability: string; isEbook: boolean; listPrice?: SaleInfoListPrice; retailPrice?: SaleInfoListPrice; @@ -77,11 +46,7 @@ export interface SaleInfo { export interface SaleInfoListPrice { amount: number; - currencyCode: CurrencyCode; -} - -export enum CurrencyCode { - Krw = 'KRW', + currencyCode: string; } export interface Offer { @@ -93,7 +58,7 @@ export interface Offer { export interface OfferListPrice { amountInMicros: number; - currencyCode: CurrencyCode; + currencyCode: string; } export interface RentalDuration { @@ -101,12 +66,6 @@ export interface RentalDuration { count: number; } -export enum Saleability { - ForSale = 'FOR_SALE', - ForSaleAndRental = 'FOR_SALE_AND_RENTAL', - NotForSale = 'NOT_FOR_SALE', -} - export interface SearchInfo { textSnippet: string; } @@ -119,14 +78,14 @@ export interface VolumeInfo { industryIdentifiers: IndustryIdentifier[]; readingModes: ReadingModes; pageCount?: number; - printType: PrintType; + printType: string; categories?: string[]; - maturityRating: MaturityRating; + maturityRating: string; allowAnonLogging: boolean; contentVersion: string; panelizationSummary: PanelizationSummary; imageLinks: ImageLinks; - language: Language; + language: string; previewLink: string; infoLink: string; canonicalVolumeLink: string; @@ -152,24 +111,11 @@ export enum Type { Other = 'OTHER', } -export enum Language { - En = 'en', - Ko = 'ko', -} - -export enum MaturityRating { - NotMature = 'NOT_MATURE', -} - export interface PanelizationSummary { containsEpubBubbles: boolean; containsImageBubbles: boolean; } -export enum PrintType { - Book = 'BOOK', -} - export interface ReadingModes { text: boolean; image: boolean; diff --git a/src/apis/models/naver_books_response.ts b/src/apis/models/naver_books_response.ts index f5f3253..23c6afe 100644 --- a/src/apis/models/naver_books_response.ts +++ b/src/apis/models/naver_books_response.ts @@ -1,12 +1,3 @@ -// To parse this data: -// -// import { Convert, NaverBooksResponse } from "./file"; -// -// const naverBooksResponse = Convert.toNaverBooksResponse(json); -// -// These functions will throw an error if the JSON doesn't -// match the expected interface, even if the JSON is valid. - export interface NaverBooksResponse { lastBuildDate: string; total: number;