Skip to content

Commit

Permalink
refactoring [v0.3.4]
Browse files Browse the repository at this point in the history
 methods x6
  • Loading branch information
SUNsung committed Sep 11, 2024
1 parent 4c7ddf9 commit 24edfa2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 20 deletions.
24 changes: 4 additions & 20 deletions methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type MethodsObj struct {
Device *MethodsDeviceObj
Orientation *MethodsOrientationObj
Variant *MethodsVariantObj

Timeout *MethodsTimeoutObj
}

type MethodsGetObj struct{ a *MpostObj }
Expand All @@ -53,6 +55,8 @@ func (a *MpostObj) newMethods() *MethodsObj {
obj.Orientation = obj.newOrientation()
obj.Variant = obj.newVariant()

obj.Timeout = obj.newTimeout()

return &obj
}

Expand Down Expand Up @@ -111,16 +115,6 @@ func (m *MethodsGetObj) DocType() enum.DocumentType {
return m.a.DocType
}

func (m *MethodsGetObj) TransactionTimeout() time.Duration {
m.a.Log.Method("GetTransactionTimeout", nil)
return acceptor.Timeout.Transaction
}

func (m *MethodsGetObj) DownloadTimeout() time.Duration {
m.a.Log.Method("GetDownloadTimeout", nil)
return acceptor.Timeout.Download
}

func (m *MethodsGetObj) Version() string {
m.a.Log.Method("GetVersion", nil)
return acceptor.Version
Expand Down Expand Up @@ -247,16 +241,6 @@ func (m *MethodsGetObj) CapBootPN() bool {

////

func (m *MethodsSetObj) TransactionTimeout(v time.Duration) {
m.a.Log.Method("SetTransactionTimeout", nil)
acceptor.Timeout.Transaction = v
}

func (m *MethodsSetObj) DownloadTimeout(v time.Duration) {
m.a.Log.Method("SetDownloadTimeout", nil)
acceptor.Timeout.Download = v
}

func (m *MethodsSetObj) AutoStack(v bool) {
m.a.Log.Method("SetAutoStack", nil)
acceptor.AutoStack = v
Expand Down
51 changes: 51 additions & 0 deletions methods_timeout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package mpost

import (
"github.com/hard-soft-ware/mpost/acceptor"
"time"
)

////////////////////////////////////

type MethodsTimeoutObj struct {
a *MpostObj
Get MethodsTimeoutGetObj
Set MethodsTimeoutSetObj
}

type MethodsTimeoutGetObj struct{ a *MpostObj }
type MethodsTimeoutSetObj struct{ a *MpostObj }

func (m *MethodsObj) newTimeout() *MethodsTimeoutObj {
obj := MethodsTimeoutObj{}

obj.a = m.a
obj.Get.a = m.a
obj.Set.a = m.a

return &obj
}

////////////////

func (m *MethodsTimeoutGetObj) Transaction() time.Duration {
m.a.Log.Method("GetTransactionTimeout", nil)
return acceptor.Timeout.Transaction
}

func (m *MethodsTimeoutGetObj) Download() time.Duration {
m.a.Log.Method("GetDownloadTimeout", nil)
return acceptor.Timeout.Download
}

//

func (m *MethodsTimeoutSetObj) Transaction(v time.Duration) {
m.a.Log.Method("SetTransactionTimeout", nil)
acceptor.Timeout.Transaction = v
}

func (m *MethodsTimeoutSetObj) Download(v time.Duration) {
m.a.Log.Method("SetDownloadTimeout", nil)
acceptor.Timeout.Download = v
}

0 comments on commit 24edfa2

Please sign in to comment.