Skip to content

Commit

Permalink
♻️ refactor: updated codebase #14
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Feb 7, 2024
1 parent 4c291b4 commit aececcd
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 101 deletions.
101 changes: 0 additions & 101 deletions pkg/ami/ami_action.go

This file was deleted.

67 changes: 67 additions & 0 deletions pkg/ami/ami_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,73 @@ func (m *AMIEvent) SetTimezone(value string) *AMIEvent {
return m
}

func (m *AMIEvent) SetAttempt(value amiRetry) *AMIEvent {
m.Attempt = value
return m
}

func (m *AMIEvent) SetPost(value *amiPost) *AMIEvent {
m.Post = value
return m
}

func (m *AMIEvent) Json() string {
return JsonString(m)
}

func NewAmiRetry() *amiRetry {
a := &amiRetry{}
return a
}

func (a *amiRetry) SetRetry(value bool) *amiRetry {
a.Retry = value
return a
}

func (a *amiRetry) SetMaxRetries(value int) *amiRetry {
a.MaxRetries = value
return a
}

func (a *amiRetry) SetDebugMode(value bool) *amiRetry {
a.DebugMode = value
return a
}

func (a *amiRetry) Json() string {
return JsonString(a)
}

func GetAmiRetrySample() *amiRetry {
a := NewAmiRetry().
SetDebugMode(false).
SetMaxRetries(2).
SetRetry(true)
return a
}

func NewAmiPost() *amiPost {
return &amiPost{}
}

func (a *amiPost) SetErr(value error) *amiPost {
a.err = value
return a
}

func (a *amiPost) Err() error {
return a.err
}

func (a *amiPost) WrapErr() string {
return a.err.Error()
}

func (a *amiPost) IsError() bool {
return a.err != nil
}

func (e *AMIEvent) OpenFullEvents(c *AMI) {
all := c.AllEvents()
defer c.Close()
Expand Down
12 changes: 12 additions & 0 deletions pkg/ami/ami_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ type AMIEvent struct {
PhonePrefix []string `json:"phone_prefix,omitempty"`
Region string `json:"region,omitempty"`
Timezone string `json:"timezone"`
Attempt amiRetry `json:"attempt"`
Post *amiPost `json:"post"`
}

type amiRetry struct {
Retry bool `json:"retry"`
MaxRetries int `json:"max_retries"`
DebugMode bool `json:"debug_mode"`
}

type amiPost struct {
err error
}

type AMIDictionary struct {
Expand Down

0 comments on commit aececcd

Please sign in to comment.