add endpointUrl to NetworkRequestFactory
This commit is contained in:
parent
c0e995819b
commit
c6bb750c92
|
@ -36,9 +36,11 @@ export class MicroPluginContainer implements MicroPluginContainerInterface {
|
|||
) {
|
||||
this.settings = settings
|
||||
this.plugin = plugin
|
||||
this.networkRequestFactory = new NetworkRequestFactory()
|
||||
this.networkClient = new NetworkClient(() => {
|
||||
return this.settings.appToken
|
||||
})
|
||||
this.networkRequestFactory = new NetworkRequestFactory(
|
||||
() => this.settings.micropubEndpoint
|
||||
)
|
||||
this.networkClient = new NetworkClient(
|
||||
() => this.settings.appToken
|
||||
)
|
||||
}
|
||||
}
|
|
@ -30,6 +30,18 @@ export interface NetworkRequestFactoryInterface {
|
|||
*/
|
||||
export class NetworkRequestFactory implements NetworkRequestFactoryInterface {
|
||||
|
||||
// Properties
|
||||
|
||||
private endpointUrl: () => string
|
||||
|
||||
// Life cycle
|
||||
|
||||
constructor(
|
||||
endpointUrl: () => string,
|
||||
) {
|
||||
this.endpointUrl = endpointUrl
|
||||
}
|
||||
|
||||
// Public
|
||||
|
||||
public makePublishRequest(
|
||||
|
@ -65,7 +77,7 @@ export class NetworkRequestFactory implements NetworkRequestFactoryInterface {
|
|||
})
|
||||
|
||||
return {
|
||||
path: '/micropub',
|
||||
url: this.endpointUrl(),
|
||||
parameters: parameters,
|
||||
method: 'POST'
|
||||
}
|
||||
|
@ -73,7 +85,7 @@ export class NetworkRequestFactory implements NetworkRequestFactoryInterface {
|
|||
|
||||
public makeConfigRequest(): NetworkRequest {
|
||||
return {
|
||||
path: '/micropub',
|
||||
url: this.endpointUrl(),
|
||||
parameters: new URLSearchParams([
|
||||
['q', 'config']
|
||||
]),
|
||||
|
@ -83,7 +95,7 @@ export class NetworkRequestFactory implements NetworkRequestFactoryInterface {
|
|||
|
||||
public makeCategoriesRequest(): NetworkRequest {
|
||||
return {
|
||||
path: '/micropub',
|
||||
url: this.endpointUrl(),
|
||||
parameters: new URLSearchParams([
|
||||
['q', 'category']
|
||||
]),
|
||||
|
|
Loading…
Reference in New Issue