apimo.js 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +37 -0
- package/.github/workflows/publish.yml +69 -0
- package/.idea/apimo.js.iml +13 -0
- package/.idea/copilotDiffState.xml +43 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/jsLinters/eslint.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +91 -0
- package/dist/src/consts/catalogs.d.ts +2 -0
- package/dist/src/consts/catalogs.js +53 -0
- package/dist/src/consts/languages.d.ts +2 -0
- package/dist/src/consts/languages.js +20 -0
- package/dist/src/core/api.d.ts +389 -0
- package/dist/src/core/api.js +157 -0
- package/dist/src/core/api.test.d.ts +1 -0
- package/dist/src/core/api.test.js +246 -0
- package/dist/src/core/converters.d.ts +4 -0
- package/dist/src/core/converters.js +4 -0
- package/dist/src/schemas/agency.d.ts +416 -0
- package/dist/src/schemas/agency.js +61 -0
- package/dist/src/schemas/common.d.ts +153 -0
- package/dist/src/schemas/common.js +47 -0
- package/dist/src/schemas/internal.d.ts +3 -0
- package/dist/src/schemas/internal.js +11 -0
- package/dist/src/schemas/property.d.ts +1500 -0
- package/dist/src/schemas/property.js +238 -0
- package/dist/src/services/storage/dummy.cache.d.ts +10 -0
- package/dist/src/services/storage/dummy.cache.js +28 -0
- package/dist/src/services/storage/dummy.cache.test.d.ts +1 -0
- package/dist/src/services/storage/dummy.cache.test.js +96 -0
- package/dist/src/services/storage/filesystem.cache.d.ts +18 -0
- package/dist/src/services/storage/filesystem.cache.js +85 -0
- package/dist/src/services/storage/filesystem.cache.test.d.ts +1 -0
- package/dist/src/services/storage/filesystem.cache.test.js +197 -0
- package/dist/src/services/storage/memory.cache.d.ts +20 -0
- package/dist/src/services/storage/memory.cache.js +62 -0
- package/dist/src/services/storage/memory.cache.test.d.ts +1 -0
- package/dist/src/services/storage/memory.cache.test.js +80 -0
- package/dist/src/services/storage/types.d.ts +16 -0
- package/dist/src/services/storage/types.js +4 -0
- package/dist/src/types/index.d.ts +4 -0
- package/dist/src/types/index.js +1 -0
- package/dist/src/utils/url.d.ts +14 -0
- package/dist/src/utils/url.js +11 -0
- package/dist/src/utils/url.test.d.ts +1 -0
- package/dist/src/utils/url.test.js +18 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +6 -0
- package/eslint.config.mjs +3 -0
- package/package.json +45 -0
- package/src/consts/catalogs.ts +55 -0
- package/src/consts/languages.ts +22 -0
- package/src/core/api.test.ts +308 -0
- package/src/core/api.ts +230 -0
- package/src/core/converters.ts +7 -0
- package/src/schemas/agency.ts +66 -0
- package/src/schemas/common.ts +67 -0
- package/src/schemas/internal.ts +13 -0
- package/src/schemas/property.ts +257 -0
- package/src/services/storage/dummy.cache.test.ts +110 -0
- package/src/services/storage/dummy.cache.ts +21 -0
- package/src/services/storage/filesystem.cache.test.ts +243 -0
- package/src/services/storage/filesystem.cache.ts +94 -0
- package/src/services/storage/memory.cache.test.ts +94 -0
- package/src/services/storage/memory.cache.ts +69 -0
- package/src/services/storage/types.ts +20 -0
- package/src/types/index.ts +5 -0
- package/src/utils/url.test.ts +21 -0
- package/src/utils/url.ts +27 -0
- package/tsconfig.json +13 -0
- package/vitest.config.ts +7 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Continuous Integration
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, develop]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, develop]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test-and-lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [20, 22, 24]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout code
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node-version }}
|
|
25
|
+
cache: yarn
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: yarn install --frozen-lockfile
|
|
29
|
+
|
|
30
|
+
- name: Run linting
|
|
31
|
+
run: yarn lint
|
|
32
|
+
|
|
33
|
+
- name: Run tests
|
|
34
|
+
run: yarn test
|
|
35
|
+
|
|
36
|
+
- name: Run test coverage
|
|
37
|
+
run: yarn test-coverage
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
name: Build, Test & Publish to NPM
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout code
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup Node.js
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: '22'
|
|
21
|
+
cache: yarn
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: yarn install --frozen-lockfile
|
|
25
|
+
|
|
26
|
+
- name: Run linting
|
|
27
|
+
run: yarn lint
|
|
28
|
+
|
|
29
|
+
- name: Run tests
|
|
30
|
+
run: yarn test
|
|
31
|
+
|
|
32
|
+
- name: Run test coverage
|
|
33
|
+
run: yarn test-coverage
|
|
34
|
+
|
|
35
|
+
build-and-publish:
|
|
36
|
+
needs: test
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
|
|
39
|
+
environment: Deploy
|
|
40
|
+
|
|
41
|
+
steps:
|
|
42
|
+
- name: Checkout code
|
|
43
|
+
uses: actions/checkout@v4
|
|
44
|
+
|
|
45
|
+
- name: Setup Node.js
|
|
46
|
+
uses: actions/setup-node@v4
|
|
47
|
+
with:
|
|
48
|
+
node-version: '22'
|
|
49
|
+
cache: yarn
|
|
50
|
+
registry-url: 'https://registry.npmjs.org'
|
|
51
|
+
|
|
52
|
+
- name: Install dependencies
|
|
53
|
+
run: yarn install --frozen-lockfile
|
|
54
|
+
|
|
55
|
+
- name: Build package
|
|
56
|
+
run: yarn build
|
|
57
|
+
|
|
58
|
+
- name: Check if dist directory exists
|
|
59
|
+
run: |
|
|
60
|
+
if [ ! -d "dist" ]; then
|
|
61
|
+
echo "Build failed: dist directory not found"
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
echo "Build successful: dist directory created"
|
|
65
|
+
|
|
66
|
+
- name: Publish to NPM
|
|
67
|
+
run: npm publish
|
|
68
|
+
env:
|
|
69
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
|
9
|
+
</content>
|
|
10
|
+
<orderEntry type="inheritedJdk" />
|
|
11
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
12
|
+
</component>
|
|
13
|
+
</module>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="CopilotDiffPersistence">
|
|
4
|
+
<option name="pendingDiffs">
|
|
5
|
+
<map>
|
|
6
|
+
<entry key="$PROJECT_DIR$/.github/workflows/ci.yml">
|
|
7
|
+
<value>
|
|
8
|
+
<PendingDiffInfo>
|
|
9
|
+
<option name="filePath" value="$PROJECT_DIR$/.github/workflows/ci.yml" />
|
|
10
|
+
<option name="updatedContent" value="name: Continuous Integration on: push: branches: [ main, develop ] pull_request: branches: [ main, develop ] jobs: test-and-lint: runs-on: ubuntu-latest strategy: matrix: node-version: [18, 20, 22] steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: 'yarn' - name: Install dependencies run: yarn install --frozen-lockfile - name: Run linting run: yarn lint - name: Run tests run: yarn test - name: Run test coverage run: yarn test-coverage - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 if: matrix.node-version == 20 with: file: ./coverage/lcov.info fail_ci_if_error: false env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}" />
|
|
11
|
+
</PendingDiffInfo>
|
|
12
|
+
</value>
|
|
13
|
+
</entry>
|
|
14
|
+
<entry key="$PROJECT_DIR$/.github/workflows/publish.yml">
|
|
15
|
+
<value>
|
|
16
|
+
<PendingDiffInfo>
|
|
17
|
+
<option name="filePath" value="$PROJECT_DIR$/.github/workflows/publish.yml" />
|
|
18
|
+
<option name="updatedContent" value="name: Build, Test & Publish to NPM on: push: tags: - 'v*' # Triggers on version tags like v1.0.0, v1.2.3, etc. workflow_dispatch: # Allows manual triggering jobs: test: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '18' cache: 'yarn' - name: Install dependencies run: yarn install --frozen-lockfile - name: Run linting run: yarn lint - name: Run tests run: yarn test - name: Run test coverage run: yarn test-coverage build-and-publish: needs: test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '18' cache: 'yarn' registry-url: 'https://registry.npmjs.org' - name: Install dependencies run: yarn install --frozen-lockfile - name: Build package run: yarn build - name: Check if dist directory exists run: | if [ ! -d "dist" ]; then echo "Build failed: dist directory not found" exit 1 fi echo "Build successful: dist directory created" - name: Publish to NPM run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}" />
|
|
19
|
+
</PendingDiffInfo>
|
|
20
|
+
</value>
|
|
21
|
+
</entry>
|
|
22
|
+
<entry key="$PROJECT_DIR$/package.json">
|
|
23
|
+
<value>
|
|
24
|
+
<PendingDiffInfo>
|
|
25
|
+
<option name="filePath" value="$PROJECT_DIR$/package.json" />
|
|
26
|
+
<option name="originalContent" value="{ "name": "apimo.js", "version": "1.0.1", "description": "A wrapper for the Apimo API with catalog caching for building custom Real Estate website using their technologies.", "main": "/dist/index.js", "repository": { "type": "git", "url": "https://github.com/Neikow/apimo.js.git" }, "homepage": "https://github.com/Neikow/apimo.js", "bugs": { "url": "https://github.com/Neikow/apimo.js/issues" }, "keywords": [ "api", "apimo", "real-estate" ], "scripts": { "dev": "", "build": "tsc", "run": "node dist/index.js", "test": "vitest run", "test-coverage": "vitest run --coverage" }, "author": "Vitaly Lysen <vitaly@lysen.dev> (https://lysen.dev)", "license": "MIT", "dependencies": { "bottleneck": "^2.19.5", "merge-anything": "^6.0.6", "zod": "^3.21.4" }, "devDependencies": { "@antfu/eslint-config": "^5.0.0", "@types/node": "^24.1.0", "@anatine/zod-mock": "^3.14.0", "@faker-js/faker": "^9.9.0", "@vitest/coverage-v8": "^3.2.4", "dotenv": "^17.2.1", "eslint": "^9.32.0", "typescript": "^5.9.2", "vitest": "^3.2.4" } } " />
|
|
27
|
+
<option name="updatedContent" value="{ "name": "apimo.js", "version": "1.0.1", "description": "A wrapper for the Apimo API with catalog caching for building custom Real Estate website using their technologies.", "main": "/dist/index.js", "repository": { "type": "git", "url": "https://github.com/Neikow/apimo.js.git" }, "homepage": "https://github.com/Neikow/apimo.js", "bugs": { "url": "https://github.com/Neikow/apimo.js/issues" }, "keywords": [ "api", "apimo", "real-estate" ], "scripts": { "dev": "", "build": "tsc", "run": "node dist/index.js", "test": "vitest run", "test-coverage": "vitest run --coverage", "lint": "eslint ." }, "author": "Vitaly Lysen <vitaly@lysen.dev> (https://lysen.dev)", "license": "MIT", "dependencies": { "bottleneck": "^2.19.5", "merge-anything": "^6.0.6", "zod": "^3.21.4" }, "devDependencies": { "@antfu/eslint-config": "^5.0.0", "@types/node": "^24.1.0", "@anatine/zod-mock": "^3.14.0", "@faker-js/faker": "^9.9.0", "@vitest/coverage-v8": "^3.2.4", "dotenv": "^17.2.1", "eslint": "^9.32.0", "typescript": "^5.9.2", "vitest": "^3.2.4" } }" />
|
|
28
|
+
</PendingDiffInfo>
|
|
29
|
+
</value>
|
|
30
|
+
</entry>
|
|
31
|
+
<entry key="$PROJECT_DIR$/src/services/storage/dummy.cache.test.ts">
|
|
32
|
+
<value>
|
|
33
|
+
<PendingDiffInfo>
|
|
34
|
+
<option name="filePath" value="$PROJECT_DIR$/src/services/storage/dummy.cache.test.ts" />
|
|
35
|
+
<option name="originalContent" value="import type { CatalogName } from '../../consts/catalogs' import type { ApiCulture } from '../../consts/languages' import { afterEach, beforeEach, describe, expect, it } from 'vitest' import { DummyCache } from './dummy.cache' import { CacheExpiredError } from './types' describe('cache - Dummy', () => { let cache: DummyCache beforeEach(() => { cache = new DummyCache() }) afterEach(() => { // No cleanup needed for dummy cache }) describe('constructor', () => { it('should create an instance without any configuration', () => { const dummyCache = new DummyCache() expect(dummyCache).toBeInstanceOf(DummyCache) }) }) describe('setEntries', () => { const culture: ApiCulture = 'en' const entries = [ { id: 1, name: 'Item 1', name_plurial: 'Items 1' }, { id: 2, name: 'Item 2', name_plurial: 'Items 2' }, ] it('should not throw when setting entries', async () => { const catalogName: CatalogName = 'book_step' await expect(cache.setEntries(catalogName, culture, entries)).resolves.toBeUndefined() }) it('should handle empty entries array', async () => { const catalogName: CatalogName = 'book_step' await expect(cache.setEntries(catalogName, culture, [])).resolves.toBeUndefined() }) it('should handle different catalog and culture combinations', async () => { await expect(cache.setEntries('book_step', 'en', entries)).resolves.toBeUndefined() await expect(cache.setEntries('property_land', 'fr', entries)).resolves.toBeUndefined() await expect(cache.setEntries('property_type', 'de', entries)).resolves.toBeUndefined() }) }) describe('getEntry', () => { const culture: ApiCulture = 'en' it('should always throw CacheExpiredError regardless of parameters', async () => { const catalogName: CatalogName = 'book_step' await expect(cache.getEntry(catalogName, culture, 1)).rejects.toThrow(CacheExpiredError) }) it('should throw CacheExpiredError for any ID', async () => { const catalogName: CatalogName = 'book_step' await expect(cache.getEntry(catalogName, culture, 999)).rejects.toThrow(CacheExpiredError) await expect(cache.getEntry(catalogName, culture, 0)).rejects.toThrow(CacheExpiredError) await expect(cache.getEntry(catalogName, culture, -1)).rejects.toThrow(CacheExpiredError) }) it('should throw CacheExpiredError for different catalogs and cultures', async () => { await expect(cache.getEntry('book_step', 'en', 1)).rejects.toThrow(CacheExpiredError) await expect(cache.getEntry('property_land', 'fr', 1)).rejects.toThrow(CacheExpiredError) await expect(cache.getEntry('property_type', 'de', 1)).rejects.toThrow(CacheExpiredError) }) it('should throw CacheExpiredError even after setting entries', async () => { const catalogName: CatalogName = 'book_step' const entries = [{ id: 1, name: 'Item 1', name_plurial: 'Items 1' }] await cache.setEntries(catalogName, culture, entries) await expect(cache.getEntry(catalogName, culture, 1)).rejects.toThrow(CacheExpiredError) }) }) }) " />
|
|
36
|
+
<option name="updatedContent" value="import type { CatalogName } from '../../consts/catalogs' import type { ApiCulture } from '../../consts/languages' import { afterEach, beforeEach, describe, expect, it } from 'vitest' import { DummyCache } from './dummy.cache' import { CacheExpiredError } from './types' describe('cache - Dummy', () => { let cache: DummyCache beforeEach(() => { cache = new DummyCache() }) afterEach(() => { // No cleanup needed for dummy cache }) describe('constructor', () => { it('should create an instance without any configuration', () => { const dummyCache = new DummyCache() expect(dummyCache).toBeInstanceOf(DummyCache) }) }) describe('setEntries', () => { const culture: ApiCulture = 'en' const entries = [ { id: 1, name: 'Item 1', name_plurial: 'Items 1' }, { id: 2, name: 'Item 2', name_plurial: 'Items 2' }, ] it('should not throw when setting entries', async () => { const catalogName: CatalogName = 'book_step' await expect(cache.setEntries(catalogName, culture, entries)).resolves.toBeUndefined() }) it('should handle empty entries array', async () => { const catalogName: CatalogName = 'book_step' await expect(cache.setEntries(catalogName, culture, [])).resolves.toBeUndefined() }) it('should handle different catalog and culture combinations', async () => { await expect(cache.setEntries('book_step', 'en', entries)).resolves.toBeUndefined() await expect(cache.setEntries('property_land', 'fr', entries)).resolves.toBeUndefined() await expect(cache.setEntries('property_type', 'de', entries)).resolves.toBeUndefined() }) }) describe('getEntry', () => { const culture: ApiCulture = 'en' it('should always throw CacheExpiredError regardless of parameters', async () => { const catalogName: CatalogName = 'book_step' await expect(cache.getEntry(catalogName, culture, 1)).rejects.toThrow(CacheExpiredError) }) it('should throw CacheExpiredError for any ID', async () => { const catalogName: CatalogName = 'book_step' await expect(cache.getEntry(catalogName, culture, 999)).rejects.toThrow(CacheExpiredError) await expect(cache.getEntry(catalogName, culture, 0)).rejects.toThrow(CacheExpiredError) await expect(cache.getEntry(catalogName, culture, -1)).rejects.toThrow(CacheExpiredError) }) it('should throw CacheExpiredError for different catalogs and cultures', async () => { await expect(cache.getEntry('book_step', 'en', 1)).rejects.toThrow(CacheExpiredError) await expect(cache.getEntry('property_land', 'fr', 1)).rejects.toThrow(CacheExpiredError) await expect(cache.getEntry('property_type', 'de', 1)).rejects.toThrow(CacheExpiredError) }) it('should throw CacheExpiredError even after setting entries', async () => { const catalogName: CatalogName = 'book_step' const entries = [{ id: 1, name: 'Item 1', name_plurial: 'Items 1' }] await cache.setEntries(catalogName, culture, entries) await expect(cache.getEntry(catalogName, culture, 1)).rejects.toThrow(CacheExpiredError) }) }) describe('behavior consistency', () => { it('should behave consistently across multiple calls', async () => { const catalogName: CatalogName = 'book_step' const culture: ApiCulture = 'en' const entries = [{ id: 1, name: 'Item 1', name_plurial: 'Items 1' }] // Multiple setEntries calls should not throw await expect(cache.setEntries(catalogName, culture, entries)).resolves.toBeUndefined() await expect(cache.setEntries(catalogName, culture, entries)).resolves.toBeUndefined() // Multiple getEntry calls should always throw await expect(cache.getEntry(catalogName, culture, 1)).rejects.toThrow(CacheExpiredError) await expect(cache.getEntry(catalogName, culture, 1)).rejects.toThrow(CacheExpiredError) }) it('should maintain dummy behavior regardless of cache state', async () => { const catalogName: CatalogName = 'book_step' const culture: ApiCulture = 'en' // Should throw before any operations await expect(cache.getEntry(catalogName, culture, 1)).rejects.toThrow(CacheExpiredError) // Should still throw after setting entries await cache.setEntries(catalogName, culture, [{ id: 1, name: 'Test', name_plurial: 'Tests' }]) await expect(cache.getEntry(catalogName, culture, 1)).rejects.toThrow(CacheExpiredError) // Should still throw after multiple operations await cache.setEntries(catalogName, culture, []) await expect(cache.getEntry(catalogName, culture, 999)).rejects.toThrow(CacheExpiredError) }) }) })" />
|
|
37
|
+
</PendingDiffInfo>
|
|
38
|
+
</value>
|
|
39
|
+
</entry>
|
|
40
|
+
</map>
|
|
41
|
+
</option>
|
|
42
|
+
</component>
|
|
43
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Apimo.js
|
|
2
|
+
|
|
3
|
+
Apimo.js is a Node.js module for interacting with the Apimo API.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
const Apimo = require('apimo.js/dist')
|
|
9
|
+
|
|
10
|
+
const api = new Apimo(
|
|
11
|
+
'<BRIDGE_ID>',
|
|
12
|
+
'<API_TOKEN>',
|
|
13
|
+
{
|
|
14
|
+
debug: true,
|
|
15
|
+
cultures: [
|
|
16
|
+
'fr_FR',
|
|
17
|
+
'en_GB',
|
|
18
|
+
],
|
|
19
|
+
updateIntervals: {
|
|
20
|
+
properties: 1000 * 60 * 5, // 5 minutes
|
|
21
|
+
catalogs: 1000 * 60 * 60 * 24, // 24 hours
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The `BRIDGE_ID` and `API_TOKEN` can be asked on the support page of Apimo.
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
The API endpoints are described on the [Apimo API documentation](https://apimo.net/en/api/webservice/).
|
|
32
|
+
|
|
33
|
+
## Wrapper
|
|
34
|
+
|
|
35
|
+
The wrapper is a set of methods that will help you to interact with the API.
|
|
36
|
+
It can cache requests in order to avoid reaching the API rate limit, which are pretty low (1000 requests per day).
|
|
37
|
+
The data can be set to be updated automatically, given a certain interval.
|
|
38
|
+
|
|
39
|
+
## Methods
|
|
40
|
+
|
|
41
|
+
### `get`
|
|
42
|
+
|
|
43
|
+
Helper method to get a property from the API.
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
api.get(['properties', 123]).then((property) => {
|
|
47
|
+
console.log(property) // == Property(id: 123, ...)
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `getProperties`
|
|
52
|
+
|
|
53
|
+
Get all properties from the API.
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
api.fetchProperties().then((properties) => {
|
|
57
|
+
console.log(properties) // [Property(...), Property(...), ...]
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
A `Property` is the data of a property, as stored in the Apimo API, it is described in
|
|
62
|
+
the [Apimo API documentation](https://apimo.net/en/api/webservice/?child=agencies/properties#get-agencies/propertiesagencies-{agency_id}-properties).
|
|
63
|
+
|
|
64
|
+
### `getAgencies`
|
|
65
|
+
|
|
66
|
+
Returns the agencies linked to the bridge.
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
api.fetchAgencies().then((agencies) => {
|
|
70
|
+
console.log(agencies) // [Agency(...), Agency(...), ...]
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
An `Agency` is the data of an agency, as stored in the Apimo API, it is described in
|
|
75
|
+
the [Apimo API documentation](https://apimo.net/en/api/webservice/?child=agencies#get-agenciesagencies).
|
|
76
|
+
|
|
77
|
+
### `convertDate`
|
|
78
|
+
|
|
79
|
+
Converts a Apimo date to a `Date` object.
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
api.convertDate('2018-01-01').then((date) => {
|
|
83
|
+
console.log(date) // == Date(2018, 0, 1)
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Installation
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install github:Neikow/apimo.js
|
|
91
|
+
```
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const API_CATALOGS: readonly ["action_type", "action_method", "book_step", "book_type", "construction_step", "contact_title", "document_type", "fees", "lead_type", "lead_step", "property_activity", "property_areas", "property_adjacency", "property_agreement", "property_availability", "property_building", "property_category", "property_subcategory", "property_condition", "property_construction_method", "property_floor", "property_flooring", "property_heating_device", "property_heating_access", "property_heating_type", "property_hot_water_device", "property_hot_water_access", "property_land", "property_lease", "property_location", "property_orientation", "property_period", "property_proximity", "property_reglementation", "property_regulation", "property_financial", "property_service", "property_service_category", "property_standing", "property_step", "property_status", "property_type", "property_subtype", "property_view_landscape", "property_view_type", "property_waste_water", "referral", "tags", "unit_area", "unit_length", "user_group"];
|
|
2
|
+
export type CatalogName = typeof API_CATALOGS[number];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const API_CATALOGS = [
|
|
2
|
+
'action_type',
|
|
3
|
+
'action_method',
|
|
4
|
+
'book_step',
|
|
5
|
+
'book_type',
|
|
6
|
+
'construction_step',
|
|
7
|
+
'contact_title',
|
|
8
|
+
'document_type',
|
|
9
|
+
'fees',
|
|
10
|
+
'lead_type',
|
|
11
|
+
'lead_step',
|
|
12
|
+
'property_activity',
|
|
13
|
+
'property_areas',
|
|
14
|
+
'property_adjacency',
|
|
15
|
+
'property_agreement',
|
|
16
|
+
'property_availability',
|
|
17
|
+
'property_building',
|
|
18
|
+
'property_category',
|
|
19
|
+
'property_subcategory',
|
|
20
|
+
'property_condition',
|
|
21
|
+
'property_construction_method',
|
|
22
|
+
'property_floor',
|
|
23
|
+
'property_flooring',
|
|
24
|
+
'property_heating_device',
|
|
25
|
+
'property_heating_access',
|
|
26
|
+
'property_heating_type',
|
|
27
|
+
'property_hot_water_device',
|
|
28
|
+
'property_hot_water_access',
|
|
29
|
+
'property_land',
|
|
30
|
+
'property_lease',
|
|
31
|
+
'property_location',
|
|
32
|
+
'property_orientation',
|
|
33
|
+
'property_period',
|
|
34
|
+
'property_proximity',
|
|
35
|
+
'property_reglementation',
|
|
36
|
+
'property_regulation',
|
|
37
|
+
'property_financial',
|
|
38
|
+
'property_service',
|
|
39
|
+
'property_service_category',
|
|
40
|
+
'property_standing',
|
|
41
|
+
'property_step',
|
|
42
|
+
'property_status',
|
|
43
|
+
'property_type',
|
|
44
|
+
'property_subtype',
|
|
45
|
+
'property_view_landscape',
|
|
46
|
+
'property_view_type',
|
|
47
|
+
'property_waste_water',
|
|
48
|
+
'referral',
|
|
49
|
+
'tags',
|
|
50
|
+
'unit_area',
|
|
51
|
+
'unit_length',
|
|
52
|
+
'user_group',
|
|
53
|
+
];
|