Skip to content

Commit

Permalink
refactor: fixes, file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
bxxf committed Apr 4, 2023
1 parent 6611fe3 commit be84848
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 243 deletions.
13 changes: 4 additions & 9 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SfmcAPI from "../dist";
import SfmcAPI from "../src";

// just importing env variables - you can skip this part
import dotenv from "dotenv";
Expand All @@ -15,18 +15,13 @@ const config = {

const someFunction = async () => {
const sfmc = SfmcAPI(config);

const result = await sfmc
.dataExtension("DataExtensionName")
.get()

const result = await sfmc.dataExtension("DataExtensionName").get();
console.log(result);

const resultSoap = await sfmc
.dataExtension("DataExtensionName")
.soap
.get(["Name", "Name2"], {
queryAllAccounts: true,
})
.soap.get(["Name", "Name2"])
.where("Name", "equals", "test");

console.log(resultSoap);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sfmc-ts",
"version": "1.1.4",
"version": "1.1.5",
"repository": {
"type": "git",
"url": "https://github.com/bxxf/sfmc-ts"
Expand Down
4 changes: 2 additions & 2 deletions src/utils/data-extension.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SfmcHelper } from "../sfmc-ts";
import { SfmcQueryBuilder, SfmcQueryBuilderWhere } from "./query-builder";
import { SfmcQueryBuilder, SfmcQueryBuilderWhere } from "./rest/query-builder";

import fetch from "node-fetch";
import { ISoapRequest, SfmcDataExtensionSoap } from "./soap/soap-client";
import { SfmcDataExtensionSoap } from "./soap/soap-client";
import { SoapQueryBuilder } from "./soap/soap-query-builder";

/**
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ApiResponse, ComparisonOperator } from "sfmc-ts";

import fetch from "node-fetch";
import { SfmcFilter as Filter } from "./filter";
import { SfmcHelper } from "../sfmc-ts";
import { SfmcFilter as Filter } from "../rest/filter";
import { SfmcHelper } from "../../sfmc-ts";

export class SfmcQueryBuilder {
private helper: SfmcHelper;
Expand Down Expand Up @@ -140,8 +140,11 @@ export class SfmcQueryBuilder {
return response.then(async (res) => {
if (res.ok) {
const data = await res.json();

const valuesArray = data.items?.length
? (data as ApiResponse).items.map((item: any) => item.values)
? (data as ApiResponse).items.map((item: any) => {
return { ...item.values, ...item.keys };
})
: [];
return valuesArray;
} else {
Expand Down
42 changes: 0 additions & 42 deletions src/utils/soap-filter.ts

This file was deleted.

180 changes: 0 additions & 180 deletions src/utils/soap-query-builder.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SfmcDataExtensionField } from "../../utils/soap/soap-client";
import { SfmcDataExtensionField } from "../soap-client";

export const createDataExtensionBody = (objectKey: string, xml: string) => `
<CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ISoapGetOptions } from "../../utils/soap/soap-client";
import { ISoapGetOptions } from "../soap-client";

export const retrieveDataExtensionBody = (
objectKey: string,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/soap/soap-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { parseStringPromise } from "xml2js";
import {
createDataExtensionBody,
createFieldsXml,
} from "../../models/soap/create";
} from "./actions/create";

import { deleteDataExtensionBody } from "../../models/soap/delete";
import { retrieveDataExtensionBody } from "../../models/soap/retrieve";
import { deleteDataExtensionBody } from "./actions/delete";
import { retrieveDataExtensionBody } from "./actions/retrieve";
import { SfmcSoapFilter, createFilterXml } from "./soap-filter";
import { SfmcHelper } from "../../sfmc-ts";

Expand Down
2 changes: 1 addition & 1 deletion tests/sfmc.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import nock from "nock";
import { ComparisonEnum } from "../src/index";
import { SfmcHelper } from "../src/sfmc-ts";
import { SfmcQueryBuilder } from "../src/utils/query-builder";
import { SfmcQueryBuilder } from "../src/utils/rest/query-builder";
import { apiConfig, authResponse, authRequestBody } from "./mock-data";
import { SfmcDataExtensionSoap } from "../src/utils/soap/soap-client";

Expand Down

0 comments on commit be84848

Please sign in to comment.