Skip to content

Commit

Permalink
Merge pull request #2 from FetcchX/development
Browse files Browse the repository at this point in the history
Fix: Structure changes
  • Loading branch information
sk1122 authored Oct 30, 2023
2 parents b30b89c + 961b16c commit 3b6db98
Show file tree
Hide file tree
Showing 28 changed files with 214 additions and 202 deletions.
19 changes: 0 additions & 19 deletions src/address-book/addressbook_generate_message.ts

This file was deleted.

17 changes: 17 additions & 0 deletions src/address-book/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import axios from "axios";
import Apis from "../utils/api-config";
import {AddressBook} from "../types/address-book/index";
import { Headers } from "../types";

export const _create = async (data: AddressBook, headers:Headers): Promise<any> => {
const req = await axios({
url: `${Apis.wAddressBookEndpoint}`,
method: "POST",
headers: headers,
data
})

const res = await req.data

return res.data
}
19 changes: 0 additions & 19 deletions src/address-book/create_addressbook.ts

This file was deleted.

17 changes: 17 additions & 0 deletions src/address-book/generate-message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import axios from "axios";
import Apis from "../utils/api-config";
import {AddressbookMessage} from "../types/address-book/index";
import { Headers } from "../types";

export const _generateMessage = async (data: AddressbookMessage, headers: Headers): Promise<any> => {
const req = await axios({
url: `${Apis.wAddressBookGenerateMessageEndpoint}`,
method: "POST",
headers: headers,
data
})

const res = await req.data

return res.data
};
8 changes: 3 additions & 5 deletions src/address-book/get_circle.ts → src/address-book/get.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import axios from "axios";
import Apis from "../utils/api-config";
import { getSecretKey } from "..";
import { Headers } from "../types";

export const get = async (owner: string): Promise<any[]> => {
export const _get = async (owner: string, headers:Headers): Promise<any[]> => {
const req = await axios({
url: `${Apis.wAddressBookEndpoint}?owner=${owner}`,
method: "GET",
headers: {
"secret-key": getSecretKey()
}
headers: headers,
})

const res = await req.data
Expand Down
38 changes: 28 additions & 10 deletions src/address-book/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import {get} from './get_circle';
import {generateMessage} from './addressbook_generate_message';
import {create} from './create_addressbook';
import {update} from './update_addressbook';

export default {
get,
generateMessage,
create,
update
import {_get} from './get';
import {_generateMessage} from './generate-message';
import {_create} from './create';
import {_update} from './update';
import {UpdateAddressbook, AddressBook, AddressbookMessage, } from "../types/address-book/index";
import { Headers } from '../types';
export default class Addressbook{
private headers: Headers

constructor(headers: Headers) {
this.headers = headers
}

get(owner: string) {
return _get(owner, this.headers)
}

generateMessage(data: AddressbookMessage) {
return _generateMessage(data, this.headers)
}

create(data: AddressBook) {
return _create(data,this.headers)
}

update(data: UpdateAddressbook) {
return _update(data, this.headers)
}
}
17 changes: 17 additions & 0 deletions src/address-book/update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Apis from "../utils/api-config";
import axios from "axios";
import {UpdateAddressbook} from "../types/address-book/index";
import { Headers } from "../types";

export const _update = async (data: UpdateAddressbook, headers:Headers): Promise<any> => {
const req = await axios({
url: Apis.wAddressBookEndpoint,
method: "PATCH",
headers: headers,
data
})

const res = await req.data

return res.data
};
19 changes: 0 additions & 19 deletions src/address-book/update_addressbook.ts

This file was deleted.

22 changes: 17 additions & 5 deletions src/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { login } from "./login";
import { generateMessage } from "./login_message";
import { _login } from "./login";
import { _generateMessage } from "./login-message";
import { Authentication, Headers } from "../types";

export default{
login,
generateMessage
export default class Auth {
private headers: Headers

constructor(headers: Headers) {
this.headers = headers
}

login(actions: Authentication) {
return _login(actions,this.headers)
}

generateMessage(owner: string) {
return _generateMessage(owner, this.headers)
}
}
8 changes: 3 additions & 5 deletions src/auth/login_message.ts → src/auth/login-message.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import axios from "axios";
import Apis from "../utils/api-config";
import { getSecretKey } from "..";
import { Headers } from '../types';

export const generateMessage = async (owner:string): Promise<any[]> => {
export const _generateMessage = async (owner:string,headers: Headers): Promise<any[]> => {
const data = {
"owner": owner
};

const req = await axios({
url: Apis.wGenerateAuthenticationMessageEndpoint,
method: 'POST',
headers: {
'secret-key': getSecretKey()
},
headers: headers,
data
})

Expand Down
8 changes: 5 additions & 3 deletions src/auth/login.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Apis from "../utils/api-config";
import axios from "axios";
import { AuthSchema } from "../types/auth";
import { Authentication } from "../types/auth";
import { Headers } from "../types";

export const login = async (auth: AuthSchema): Promise<any[]> => {
export const _login = async (auth: Authentication,headers:Headers): Promise<any[]> => {
const req = await axios({
url: Apis.wAuthenticationEndpoint,
method: 'POST',
data: auth
data: auth,
headers: headers
})

const res = await req.data
Expand Down
10 changes: 4 additions & 6 deletions src/identity/create_identity.ts → src/identity/create.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import axios from "axios";
import Apis from "../utils/api-config";
import {identitySchema} from "../types/identity";
import { getSecretKey } from "..";
import {IdentityIntent} from "../types/identity";
import { Headers } from "../types";

export const create = async (data: identitySchema): Promise<any[]> => {
export const _create = async (data: IdentityIntent, headers:Headers): Promise<any[]> => {
const req = await axios({
url: Apis.wGetIdentityEndpoint,
method: "POST",
headers: {
"secret-key": getSecretKey()
},
headers: headers,
data
})

Expand Down
17 changes: 17 additions & 0 deletions src/identity/generate-message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import axios from "axios";
import Apis from "../utils/api-config";
import { GenerateIdentityMessage } from "../types/identity";
import { Headers } from "../types";

export const _generateMessage = async (data: GenerateIdentityMessage, headers: Headers): Promise<any[]> => {

const req = await axios({
url: Apis.wIdentityGenerateMessageEndpoint,
method: "POST",
headers: headers,
data
})

const res = await req.data;
return res.data;
}
27 changes: 0 additions & 27 deletions src/identity/generateIdentityMessage.test.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/identity/generate_identity_message.ts

This file was deleted.

8 changes: 3 additions & 5 deletions src/identity/get.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { getSecretKey } from "..";
import Apis from "../utils/api-config";
import axios from "axios";
import { Headers } from '../types';

export const get = async (id: string): Promise<any[]> => {
export const _get = async (id: string, headers: Headers): Promise<any[]> => {
const req = await axios({
url: `${Apis.wGetIdentityEndpoint}?id=${id}`,
method: "GET",
headers: {
"secret-key":getSecretKey()
}
headers: headers
})

const res = await req.data
Expand Down
7 changes: 0 additions & 7 deletions src/identity/getIdentity.test.ts

This file was deleted.

30 changes: 23 additions & 7 deletions src/identity/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import {get} from "./get";
import {create} from "./create_identity";
import {generateMessage} from "./generate_identity_message";
import {_get} from "./get";
import {_generateMessage} from "./generate-message";
import {_create} from "./create";
import { Headers } from '../types';
import {GenerateIdentityMessage, IdentityIntent} from "../types/identity";
export default class Identity {

private headers: Headers

constructor(headers: Headers) {
this.headers = headers
}

export default {
get,
create,
generateMessage
get(id: string) {
return _get(id, this.headers)
}

generateMessage(data: GenerateIdentityMessage) {
return _generateMessage(data, this.headers)
}

create(data: IdentityIntent) {
return _create(data,this.headers)
}
}
Loading

0 comments on commit 3b6db98

Please sign in to comment.