Skip to content

Commit 2055f14

Browse files
authored
Add files via upload
0 parents  commit 2055f14

33 files changed

+1470
-0
lines changed

api.module.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
2+
import { Configuration } from './configuration';
3+
import { HttpClient } from '@angular/common/http';
4+
5+
6+
import { DefaultService } from './api/default.service';
7+
8+
@NgModule({
9+
imports: [],
10+
declarations: [],
11+
exports: [],
12+
providers: [
13+
DefaultService ]
14+
})
15+
export class ApiModule {
16+
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders {
17+
return {
18+
ngModule: ApiModule,
19+
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
20+
};
21+
}
22+
23+
constructor( @Optional() @SkipSelf() parentModule: ApiModule,
24+
@Optional() http: HttpClient) {
25+
if (parentModule) {
26+
throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
27+
}
28+
if (!http) {
29+
throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
30+
'See also https://github.com/angular/angular/issues/20575');
31+
}
32+
}
33+
}

api/api.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './default.service';
2+
import { DefaultService } from './default.service';
3+
export const APIS = [DefaultService];

api/default.service.ts

+409
Large diffs are not rendered by default.

configuration.ts

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
export interface ConfigurationParameters {
2+
apiKeys?: {[ key: string ]: string};
3+
username?: string;
4+
password?: string;
5+
accessToken?: string | (() => string);
6+
basePath?: string;
7+
withCredentials?: boolean;
8+
}
9+
10+
export class Configuration {
11+
apiKeys?: {[ key: string ]: string};
12+
username?: string;
13+
password?: string;
14+
accessToken?: string | (() => string);
15+
basePath?: string;
16+
withCredentials?: boolean;
17+
18+
constructor(configurationParameters: ConfigurationParameters = {}) {
19+
this.apiKeys = configurationParameters.apiKeys;
20+
this.username = configurationParameters.username;
21+
this.password = configurationParameters.password;
22+
this.accessToken = configurationParameters.accessToken;
23+
this.basePath = configurationParameters.basePath;
24+
this.withCredentials = configurationParameters.withCredentials;
25+
}
26+
27+
/**
28+
* Select the correct content-type to use for a request.
29+
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
30+
* If no content type is found return the first found type if the contentTypes is not empty
31+
* @param contentTypes - the array of content types that are available for selection
32+
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
33+
*/
34+
public selectHeaderContentType (contentTypes: string[]): string | undefined {
35+
if (contentTypes.length == 0) {
36+
return undefined;
37+
}
38+
39+
let type = contentTypes.find(x => this.isJsonMime(x));
40+
if (type === undefined) {
41+
return contentTypes[0];
42+
}
43+
return type;
44+
}
45+
46+
/**
47+
* Select the correct accept content-type to use for a request.
48+
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
49+
* If no content type is found return the first found type if the contentTypes is not empty
50+
* @param accepts - the array of content types that are available for selection.
51+
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
52+
*/
53+
public selectHeaderAccept(accepts: string[]): string | undefined {
54+
if (accepts.length == 0) {
55+
return undefined;
56+
}
57+
58+
let type = accepts.find(x => this.isJsonMime(x));
59+
if (type === undefined) {
60+
return accepts[0];
61+
}
62+
return type;
63+
}
64+
65+
/**
66+
* Check if the given MIME is a JSON MIME.
67+
* JSON MIME examples:
68+
* application/json
69+
* application/json; charset=UTF8
70+
* APPLICATION/JSON
71+
* application/vnd.company+json
72+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
73+
* @return True if the given MIME is JSON, false otherwise.
74+
*/
75+
public isJsonMime(mime: string): boolean {
76+
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
77+
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
78+
}
79+
}

encoder.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { HttpUrlEncodingCodec } from '@angular/common/http';
2+
3+
/**
4+
* CustomHttpUrlEncodingCodec
5+
* Fix plus sign (+) not encoding, so sent as blank space
6+
* See: https://github.com/angular/angular/issues/11058#issuecomment-247367318
7+
*/
8+
export class CustomHttpUrlEncodingCodec extends HttpUrlEncodingCodec {
9+
encodeKey(k: string): string {
10+
k = super.encodeKey(k);
11+
return k.replace(/\+/gi, '%2B');
12+
}
13+
encodeValue(v: string): string {
14+
v = super.encodeValue(v);
15+
return v.replace(/\+/gi, '%2B');
16+
}
17+
}
18+

git_push.sh

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3+
#
4+
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
5+
6+
git_user_id=$1
7+
git_repo_id=$2
8+
release_note=$3
9+
10+
if [ "$git_user_id" = "" ]; then
11+
git_user_id="GIT_USER_ID"
12+
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
13+
fi
14+
15+
if [ "$git_repo_id" = "" ]; then
16+
git_repo_id="GIT_REPO_ID"
17+
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
18+
fi
19+
20+
if [ "$release_note" = "" ]; then
21+
release_note="Minor update"
22+
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
23+
fi
24+
25+
# Initialize the local directory as a Git repository
26+
git init
27+
28+
# Adds the files in the local repository and stages them for commit.
29+
git add .
30+
31+
# Commits the tracked changes and prepares them to be pushed to a remote repository.
32+
git commit -m "$release_note"
33+
34+
# Sets the new remote
35+
git_remote=`git remote`
36+
if [ "$git_remote" = "" ]; then # git remote not defined
37+
38+
if [ "$GIT_TOKEN" = "" ]; then
39+
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
40+
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
41+
else
42+
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
43+
fi
44+
45+
fi
46+
47+
git pull origin master
48+
49+
# Pushes (Forces) the changes in the local repository up to the remote repository
50+
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
51+
git push origin master 2>&1 | grep -v 'To https'
52+

index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from './api/api';
2+
export * from './model/models';
3+
export * from './variables';
4+
export * from './configuration';
5+
export * from './api.module';

model/brandedFoodObject.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Chomp Food Database API Documentation
3+
* __Important:__ - An __[API key](https://chompthis.com/api/)__ is required for access to this API. - Get yours at __[https://chompthis.com/api](https://chompthis.com/api/)__. ----- __Getting Started:__ - __[Subscribe](https://chompthis.com/api/#pricing)__ to the API. - Scroll down and click the \"__Authorize__\" button. - Enter your API key into the \"__value__\" input, click the \"__Authorize__\" button, then click the \"__Close__\" button. - Scroll down to the section titled \"__default__\" and click on the API endpoint you wish to use. - Click the \"__Try it out__\" button. - Enter the information the endpoint requires. - Click the \"__Execute__\" button. __Example:__ - __[View example](https://raw.githubusercontent.com/chompfoods/examples/master/response-object.json)__ API response object. ----- __How Do I Find My API Key?__ - Your API key was sent to the email address you used to create your subscription. - You will also find your API key in the __[Client Center](https://chompthis.com/api/manage.php)__. - _Read __[this article](https://desk.zoho.com/portal/chompthis/kb/articles/how-do-i-find-my-api-key)__ for more information._ ||| | ------- | -------- | | [Knowledge Base](https://desk.zoho.com/portal/chompthis/kb/chomp) | [Pricing](https://chompthis.com/api/) | | [Attribution](https://chompthis.com/api/docs/attribution.php) | [Cost Calculator](https://chompthis.com/api/cost-calculator.php) | | [Terms & License](https://chompthis.com/api/terms.php) | [Database Search](https://chompthis.com/api/lookup.php) | | [Support](https://chompthis.com/api/ticket-new.php) | [Query Builder](https://chompthis.com/api/build.php) | | [Client Center](https://chompthis.com/api/manage.php) | |
4+
*
5+
* OpenAPI spec version: 1.0.0-oas3
6+
*
7+
*
8+
* NOTE: This class is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the class manually.
11+
*/
12+
import { BrandedFoodObjectItems } from './brandedFoodObjectItems';
13+
14+
/**
15+
* Please read the description of each field in this API response object example. By default, the value of each field is __null__. This indicates an unknown state or that no data exists.
16+
*/
17+
export interface BrandedFoodObject {
18+
/**
19+
* An array containing an object for each individual item returned by your API call.
20+
*/
21+
items?: Array<BrandedFoodObjectItems>;
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Chomp Food Database API Documentation
3+
* __Important:__ - An __[API key](https://chompthis.com/api/)__ is required for access to this API. - Get yours at __[https://chompthis.com/api](https://chompthis.com/api/)__. ----- __Getting Started:__ - __[Subscribe](https://chompthis.com/api/#pricing)__ to the API. - Scroll down and click the \"__Authorize__\" button. - Enter your API key into the \"__value__\" input, click the \"__Authorize__\" button, then click the \"__Close__\" button. - Scroll down to the section titled \"__default__\" and click on the API endpoint you wish to use. - Click the \"__Try it out__\" button. - Enter the information the endpoint requires. - Click the \"__Execute__\" button. __Example:__ - __[View example](https://raw.githubusercontent.com/chompfoods/examples/master/response-object.json)__ API response object. ----- __How Do I Find My API Key?__ - Your API key was sent to the email address you used to create your subscription. - You will also find your API key in the __[Client Center](https://chompthis.com/api/manage.php)__. - _Read __[this article](https://desk.zoho.com/portal/chompthis/kb/articles/how-do-i-find-my-api-key)__ for more information._ ||| | ------- | -------- | | [Knowledge Base](https://desk.zoho.com/portal/chompthis/kb/chomp) | [Pricing](https://chompthis.com/api/) | | [Attribution](https://chompthis.com/api/docs/attribution.php) | [Cost Calculator](https://chompthis.com/api/cost-calculator.php) | | [Terms & License](https://chompthis.com/api/terms.php) | [Database Search](https://chompthis.com/api/lookup.php) | | [Support](https://chompthis.com/api/ticket-new.php) | [Query Builder](https://chompthis.com/api/build.php) | | [Client Center](https://chompthis.com/api/manage.php) | |
4+
*
5+
* OpenAPI spec version: 1.0.0-oas3
6+
*
7+
*
8+
* NOTE: This class is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the class manually.
11+
*/
12+
13+
/**
14+
* An object containing the multiplication factors to be used when calculating energy from macronutrients for a specific food.
15+
*/
16+
export interface BrandedFoodObjectCalorieConversionFactor {
17+
/**
18+
* The multiplication factor for protein
19+
*/
20+
proteinValue?: number;
21+
/**
22+
* The multiplication factor for fat
23+
*/
24+
fatValue?: number;
25+
/**
26+
* The multiplication factor for carbohydrates
27+
*/
28+
carbohydrateValue?: number;
29+
}

model/brandedFoodObjectComponents.ts

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Chomp Food Database API Documentation
3+
* __Important:__ - An __[API key](https://chompthis.com/api/)__ is required for access to this API. - Get yours at __[https://chompthis.com/api](https://chompthis.com/api/)__. ----- __Getting Started:__ - __[Subscribe](https://chompthis.com/api/#pricing)__ to the API. - Scroll down and click the \"__Authorize__\" button. - Enter your API key into the \"__value__\" input, click the \"__Authorize__\" button, then click the \"__Close__\" button. - Scroll down to the section titled \"__default__\" and click on the API endpoint you wish to use. - Click the \"__Try it out__\" button. - Enter the information the endpoint requires. - Click the \"__Execute__\" button. __Example:__ - __[View example](https://raw.githubusercontent.com/chompfoods/examples/master/response-object.json)__ API response object. ----- __How Do I Find My API Key?__ - Your API key was sent to the email address you used to create your subscription. - You will also find your API key in the __[Client Center](https://chompthis.com/api/manage.php)__. - _Read __[this article](https://desk.zoho.com/portal/chompthis/kb/articles/how-do-i-find-my-api-key)__ for more information._ ||| | ------- | -------- | | [Knowledge Base](https://desk.zoho.com/portal/chompthis/kb/chomp) | [Pricing](https://chompthis.com/api/) | | [Attribution](https://chompthis.com/api/docs/attribution.php) | [Cost Calculator](https://chompthis.com/api/cost-calculator.php) | | [Terms & License](https://chompthis.com/api/terms.php) | [Database Search](https://chompthis.com/api/lookup.php) | | [Support](https://chompthis.com/api/ticket-new.php) | [Query Builder](https://chompthis.com/api/build.php) | | [Client Center](https://chompthis.com/api/manage.php) | |
4+
*
5+
* OpenAPI spec version: 1.0.0-oas3
6+
*
7+
*
8+
* NOTE: This class is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the class manually.
11+
*/
12+
13+
/**
14+
* An object containing information on a specific component of this food item
15+
*/
16+
export interface BrandedFoodObjectComponents {
17+
/**
18+
* The kind of component, e.g. bone
19+
*/
20+
name?: string;
21+
/**
22+
* The weight of the component as a percentage of the total weight of the food
23+
*/
24+
pctWeight?: number;
25+
/**
26+
* The weight of the component in grams
27+
*/
28+
gramWeight?: number;
29+
/**
30+
* Whether the component is refuse, i.e. not edible
31+
*/
32+
isRefuse?: boolean;
33+
/**
34+
* The number of obersvations on which the measure is based
35+
*/
36+
dataPoints?: number;
37+
}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Chomp Food Database API Documentation
3+
* __Important:__ - An __[API key](https://chompthis.com/api/)__ is required for access to this API. - Get yours at __[https://chompthis.com/api](https://chompthis.com/api/)__. ----- __Getting Started:__ - __[Subscribe](https://chompthis.com/api/#pricing)__ to the API. - Scroll down and click the \"__Authorize__\" button. - Enter your API key into the \"__value__\" input, click the \"__Authorize__\" button, then click the \"__Close__\" button. - Scroll down to the section titled \"__default__\" and click on the API endpoint you wish to use. - Click the \"__Try it out__\" button. - Enter the information the endpoint requires. - Click the \"__Execute__\" button. __Example:__ - __[View example](https://raw.githubusercontent.com/chompfoods/examples/master/response-object.json)__ API response object. ----- __How Do I Find My API Key?__ - Your API key was sent to the email address you used to create your subscription. - You will also find your API key in the __[Client Center](https://chompthis.com/api/manage.php)__. - _Read __[this article](https://desk.zoho.com/portal/chompthis/kb/articles/how-do-i-find-my-api-key)__ for more information._ ||| | ------- | -------- | | [Knowledge Base](https://desk.zoho.com/portal/chompthis/kb/chomp) | [Pricing](https://chompthis.com/api/) | | [Attribution](https://chompthis.com/api/docs/attribution.php) | [Cost Calculator](https://chompthis.com/api/cost-calculator.php) | | [Terms & License](https://chompthis.com/api/terms.php) | [Database Search](https://chompthis.com/api/lookup.php) | | [Support](https://chompthis.com/api/ticket-new.php) | [Query Builder](https://chompthis.com/api/build.php) | | [Client Center](https://chompthis.com/api/manage.php) | |
4+
*
5+
* OpenAPI spec version: 1.0.0-oas3
6+
*
7+
*
8+
* NOTE: This class is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the class manually.
11+
*/
12+
13+
/**
14+
* An object containing additional information on the countries where this item is found
15+
*/
16+
export interface BrandedFoodObjectCountryDetails {
17+
/**
18+
* The number of countries where English is the country's primary language
19+
*/
20+
englishSpeaking?: number;
21+
/**
22+
* The number of countries where English is not the country's primary language
23+
*/
24+
nonEnglishSpeaking?: number;
25+
}

model/brandedFoodObjectDietFlags.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Chomp Food Database API Documentation
3+
* __Important:__ - An __[API key](https://chompthis.com/api/)__ is required for access to this API. - Get yours at __[https://chompthis.com/api](https://chompthis.com/api/)__. ----- __Getting Started:__ - __[Subscribe](https://chompthis.com/api/#pricing)__ to the API. - Scroll down and click the \"__Authorize__\" button. - Enter your API key into the \"__value__\" input, click the \"__Authorize__\" button, then click the \"__Close__\" button. - Scroll down to the section titled \"__default__\" and click on the API endpoint you wish to use. - Click the \"__Try it out__\" button. - Enter the information the endpoint requires. - Click the \"__Execute__\" button. __Example:__ - __[View example](https://raw.githubusercontent.com/chompfoods/examples/master/response-object.json)__ API response object. ----- __How Do I Find My API Key?__ - Your API key was sent to the email address you used to create your subscription. - You will also find your API key in the __[Client Center](https://chompthis.com/api/manage.php)__. - _Read __[this article](https://desk.zoho.com/portal/chompthis/kb/articles/how-do-i-find-my-api-key)__ for more information._ ||| | ------- | -------- | | [Knowledge Base](https://desk.zoho.com/portal/chompthis/kb/chomp) | [Pricing](https://chompthis.com/api/) | | [Attribution](https://chompthis.com/api/docs/attribution.php) | [Cost Calculator](https://chompthis.com/api/cost-calculator.php) | | [Terms & License](https://chompthis.com/api/terms.php) | [Database Search](https://chompthis.com/api/lookup.php) | | [Support](https://chompthis.com/api/ticket-new.php) | [Query Builder](https://chompthis.com/api/build.php) | | [Client Center](https://chompthis.com/api/manage.php) | |
4+
*
5+
* OpenAPI spec version: 1.0.0-oas3
6+
*
7+
*
8+
* NOTE: This class is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the class manually.
11+
*/
12+
13+
/**
14+
* An object containing information on an individual ingredient that was flagged as potentially not being compatible with a certain diet
15+
*/
16+
export interface BrandedFoodObjectDietFlags {
17+
/**
18+
* Ingredient name
19+
*/
20+
ingredient?: string;
21+
/**
22+
* Description of the ingredient
23+
*/
24+
ingredientDescription?: string;
25+
/**
26+
* Name of the diet with which this ingredient may not be compatible
27+
*/
28+
dietLabel?: string;
29+
/**
30+
* A description of if we believe this ingredient is compatible with the diet
31+
*/
32+
isCompatible?: string;
33+
/**
34+
* A numeric representation of if we believe this ingredient is compatible with the diet. Higher values indicate more compatibility
35+
*/
36+
compatibilityLevel?: number;
37+
/**
38+
* A description of how we graded this ingredient for compatibility with the diet
39+
*/
40+
compatibilityDescription?: string;
41+
/**
42+
* Boolean representing if the ingredient is a known allergen
43+
*/
44+
isAllergen?: boolean;
45+
}

0 commit comments

Comments
 (0)