cf-clone 1.0.0

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/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # 🏠 CASAFARI
2
+
3
+ Casafari legacy API to casafari services
4
+
5
+ Created by [@lionhard83](https://github.com/lionhard83)
6
+ Docs: https://developer.casafari.com/
7
+
8
+ ## How to use
9
+
10
+ ```
11
+ import casafari from "casafari";
12
+ export const cf = casafari("Token YOUR_TOKEN");
13
+ // ...
14
+ await cf.getTypes();
15
+ await cf.getFeeds();
16
+ await cf.createFeed(feed);
17
+ await cf.deleteFeed(feedId);
18
+
19
+ ```
@@ -0,0 +1,14 @@
1
+ import { Data, Feed, FeedPayload, FeedResponseOnCreate, QueryFilter } from "casafari";
2
+ declare const _default: ({ token, baseUrl }: {
3
+ token: string;
4
+ baseUrl: string;
5
+ }) => {
6
+ getFeed: (id: number, params?: Partial<QueryFilter>) => Promise<Data>;
7
+ deleteFeed: (id: number) => Promise<{
8
+ success: boolean;
9
+ }>;
10
+ createFeed: (body: FeedPayload) => Promise<FeedResponseOnCreate>;
11
+ getFeeds: () => Promise<Feed[]>;
12
+ setToken: (token: string) => void;
13
+ };
14
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ var axios_1 = __importDefault(require("axios"));
54
+ exports.default = (function (_a) {
55
+ var token = _a.token, baseUrl = _a.baseUrl;
56
+ var config = { headers: { Authorization: token } };
57
+ var setToken = function (token) {
58
+ config.headers.Authorization = token;
59
+ };
60
+ var getFeeds = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
61
+ switch (_a.label) {
62
+ case 0: return [4 /*yield*/, axios_1.default.get("".concat(baseUrl, "/v1/feeds"), config)];
63
+ case 1: return [2 /*return*/, (_a.sent()).data];
64
+ }
65
+ }); }); };
66
+ var createFeed = function (body) { return __awaiter(void 0, void 0, void 0, function () {
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0: return [4 /*yield*/, axios_1.default.post("".concat(baseUrl, "/v1/feeds"), body, config)];
70
+ case 1: return [2 /*return*/, (_a.sent()).data];
71
+ }
72
+ });
73
+ }); };
74
+ var deleteFeed = function (id) { return __awaiter(void 0, void 0, void 0, function () {
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
77
+ case 0: return [4 /*yield*/, axios_1.default.delete("".concat(baseUrl, "/v1/feeds/").concat(id), config)];
78
+ case 1: return [2 /*return*/, (_a.sent()).data];
79
+ }
80
+ });
81
+ }); };
82
+ var getFeed = function (id, params) { return __awaiter(void 0, void 0, void 0, function () {
83
+ return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0: return [4 /*yield*/, axios_1.default.get("".concat(baseUrl, "/v1/feeds/").concat(id), __assign(__assign({}, config), { params: params }))];
86
+ case 1: return [2 /*return*/, (_a.sent()).data];
87
+ }
88
+ });
89
+ }); };
90
+ return {
91
+ getFeed: getFeed,
92
+ deleteFeed: deleteFeed,
93
+ createFeed: createFeed,
94
+ getFeeds: getFeeds,
95
+ setToken: setToken,
96
+ };
97
+ });
@@ -0,0 +1,95 @@
1
+ export type Locate = {
2
+ location_id: number;
3
+ name: string;
4
+ administrative_level: string;
5
+ zip_codes: string[];
6
+ };
7
+ export type Coordinate = {
8
+ latitude: number;
9
+ longitude: number;
10
+ };
11
+ export type ContactsInfo = {
12
+ name: string | null;
13
+ email: string | null;
14
+ phone: string;
15
+ };
16
+ export type Features = {
17
+ floor: string;
18
+ orientation: string | null;
19
+ view?: string | null;
20
+ views: string[] | null;
21
+ direction?: string | null;
22
+ directions: string[] | null;
23
+ characteristics: string[];
24
+ };
25
+ export type Result = {
26
+ alert_id: number;
27
+ listing_id: number;
28
+ ref: string;
29
+ alert_type: string;
30
+ alert_subtype: string;
31
+ old_value: string;
32
+ new_value: string;
33
+ alert_date: string;
34
+ alert_date_and_time: string | null;
35
+ property_url: string;
36
+ listing_url: string;
37
+ property_id: number;
38
+ type: string;
39
+ type_group: string;
40
+ location: Locate;
41
+ locations_structure: Locate[];
42
+ address: string;
43
+ coordinates: Coordinate;
44
+ condition: string;
45
+ contacts_info: ContactsInfo;
46
+ total_area: number;
47
+ living_area: number;
48
+ plot_area: number;
49
+ terrace_area: number;
50
+ bedrooms: number;
51
+ rooms: number;
52
+ bathrooms: number;
53
+ features: Features;
54
+ construction_year: number;
55
+ operations: string[];
56
+ is_bank_property: boolean;
57
+ is_auction_property: boolean;
58
+ is_new_development_property: boolean;
59
+ is_private_property: boolean;
60
+ sale_status: string;
61
+ sale_currency: string;
62
+ sale_price_base: number;
63
+ sale_price: number;
64
+ sale_price_per_sqm: number;
65
+ rent_status: string;
66
+ rent_currency: string;
67
+ rent_price_base: number;
68
+ rent_price: number;
69
+ rent_price_per_sqm: number;
70
+ rent_period: string;
71
+ agency: string;
72
+ agent: string;
73
+ source_name: string;
74
+ description: string;
75
+ thumbnails: string[];
76
+ pictures: string[];
77
+ energy_certificate: string;
78
+ listing_old_url?: string | null;
79
+ listing_uid?: string;
80
+ zip_code?: string | null;
81
+ cadastral_reference?: string | null;
82
+ sale_price_per_sqm_base?: number;
83
+ rent_price_per_sqm_base?: number;
84
+ agency_legal_id?: string;
85
+ energy_rating?: string;
86
+ heating_type?: string;
87
+ created_at: string;
88
+ updated_at: string;
89
+ };
90
+ export type Data = {
91
+ count: number;
92
+ next: string | null;
93
+ previous: string | null;
94
+ results: Result[];
95
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,67 @@
1
+ import { Coordinate } from "./Apartment";
2
+ export type OtherFilter = {
3
+ types: ("apartment" | "studio" | "duplex" | "penthouse" | "country_house" | "house" | "palace" | "townhouse" | "villa" | "country_estate" | "chalet" | "bungalow" | "retail" | "office" | "industrial" | "warehouse" | "hotel" | "building" | "other_commercial" | "plot" | "room" | "parking" | "garage" | "other" | "apartment_building" | "office_building" | "mix_use_building")[];
4
+ custom_locations: Array<Coordinate[]>;
5
+ location_ids: number[];
6
+ conditions: ("used" | "ruin" | "very-good" | "new" | "other")[];
7
+ statuses: ("active" | "reserved" | "hold" | "sold" | "rented")[];
8
+ alert_date_from: string;
9
+ alert_date_to: string;
10
+ price_from: number;
11
+ price_to: number;
12
+ price_per_sqm_from: number;
13
+ price_per_sqm_to: number;
14
+ bedrooms_from: number;
15
+ bedrooms_to: number;
16
+ total_area_from: number;
17
+ total_area_to: number;
18
+ construction_year_from: number;
19
+ floors: ("no_floor" | "ground" | "middle" | "top")[];
20
+ views: ("water" | "landscape" | "city" | "golf" | "park")[];
21
+ directions: ("north" | "south" | "east" | "west")[];
22
+ characteristics: ("balcony" | "elevator" | "no_elevator" | "garage" | "garden" | "parking" | "storage" | "swimming_pool" | "terrace" | "rental_license" | "furniture" | "rented_out" | "life_annuity")[];
23
+ private: boolean;
24
+ auction: boolean;
25
+ bank: boolean;
26
+ new_development: boolean;
27
+ without_agencies: string[];
28
+ with_agencies: string[];
29
+ listing_agents: string[];
30
+ exclusive: boolean;
31
+ ref_numbers: string[];
32
+ has_phone: boolean;
33
+ bathrooms_from: number;
34
+ bathrooms_to: number;
35
+ };
36
+ export type Operation = "sale" | "sold" | "sale_hold" | "rent" | "rented" | "rent_hold";
37
+ export type OperationPayload = {
38
+ search_operations: Operation;
39
+ };
40
+ export type Filter = {
41
+ operation: Operation;
42
+ } & Partial<OtherFilter>;
43
+ export type FeedPayload = {
44
+ name: string;
45
+ filter: Filter;
46
+ };
47
+ export type Feed = {
48
+ id: number;
49
+ user: string;
50
+ name: string;
51
+ };
52
+ export type FeedResponseOnCreate = Feed & {
53
+ filter: Filter;
54
+ };
55
+ type OrderByKey = "alert_date" | "alert_id" | "created_at" | "updated_at";
56
+ export type OrderBy = OrderByKey | `-${OrderByKey}`;
57
+ export type QueryFilter = {
58
+ limit: number;
59
+ offset: number;
60
+ order_by: OrderBy;
61
+ alert_date_from: string;
62
+ alert_date_to: string;
63
+ alert_subtype: "new" | "price_up" | "price_down" | "reserved" | "delisted" | "sold";
64
+ created_at_from: string;
65
+ created_at_to: string;
66
+ };
67
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export type Type = {
2
+ group: string;
3
+ names: string[];
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "cf-clone",
3
+ "version": "1.0.0",
4
+ "description": "Cf api legacy",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "start": "tsc && node ./dist/index.js",
9
+ "test": "echo \"Error: no test specified\" && exit 1",
10
+ "build": "tsc",
11
+ "prepare": "npm run build"
12
+ },
13
+ "keywords": [
14
+ "real-estates",
15
+ "api-doc"
16
+ ],
17
+ "author": "Carlo Leonardi <carloleonardi83@gmail.com>",
18
+ "license": "MIT",
19
+ "devDependencies": {
20
+ "typescript": "4.9.5"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/lionhard83/cf-clone"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/lionhard83/cf-clone/issues"
28
+ },
29
+ "homepage": "https://github.com/lionhard83/cf-clone#readme",
30
+ "dependencies": {
31
+ "axios": "^1.11.0",
32
+ "casafari": "^3.3.1"
33
+ }
34
+ }