feat(ModemAuthentication): add pin
This commit is contained in:
@@ -5,6 +5,7 @@ type SetModemOptions struct {
|
|||||||
Type *string
|
Type *string
|
||||||
Username *string
|
Username *string
|
||||||
Password *string
|
Password *string
|
||||||
|
Pin *string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetModemOptionsFunc func(opts *SetModemOptions)
|
type SetModemOptionsFunc func(opts *SetModemOptions)
|
||||||
@@ -34,8 +35,15 @@ func WithUsername(value string) SetModemOptionsFunc {
|
|||||||
opts.Username = &value
|
opts.Username = &value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithPassword(value string) SetModemOptionsFunc {
|
func WithPassword(value string) SetModemOptionsFunc {
|
||||||
return func(opts *SetModemOptions) {
|
return func(opts *SetModemOptions) {
|
||||||
opts.Password = &value
|
opts.Password = &value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithPin(value string) SetModemOptionsFunc {
|
||||||
|
return func(opts *SetModemOptions) {
|
||||||
|
opts.Pin = &value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -3,12 +3,13 @@ package model
|
|||||||
// type : null, pap_chap, pap, chap
|
// type : null, pap_chap, pap, chap
|
||||||
// if type selected, username and password are mandatory
|
// if type selected, username and password are mandatory
|
||||||
type ModemAuthentication struct {
|
type ModemAuthentication struct {
|
||||||
Authentication struct {
|
Authentication *struct {
|
||||||
Apn string `json:"apn"`
|
Apn string `json:"apn,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
} `json:"authentication"`
|
} `json:"authentication,omitempty"`
|
||||||
|
Pin string `json:"pin,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModemConfiguration struct {
|
type ModemConfiguration struct {
|
||||||
|
@@ -366,20 +366,29 @@ func (o *Operations) SetBaseCorrections(ctx context.Context, funcs ...protocol.S
|
|||||||
func (o *Operations) SetModem(ctx context.Context, funcs ...protocol.SetModemOptionsFunc) error {
|
func (o *Operations) SetModem(ctx context.Context, funcs ...protocol.SetModemOptionsFunc) error {
|
||||||
opts := protocol.NewSetModemOptions(funcs...)
|
opts := protocol.NewSetModemOptions(funcs...)
|
||||||
modem := &model.ModemAuthentication{}
|
modem := &model.ModemAuthentication{}
|
||||||
if opts.Apn != nil {
|
if opts.Pin != nil {
|
||||||
modem.Authentication.Apn = *opts.Apn
|
modem.Pin = *opts.Pin
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Type != nil {
|
if opts.Apn != nil || opts.Type != nil || opts.Username != nil || opts.Password != nil {
|
||||||
modem.Authentication.Type = *opts.Type
|
modem.Authentication = &struct {
|
||||||
}
|
Apn string `json:"apn,omitempty"`
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
if opts.Password != nil {
|
Username string `json:"username,omitempty"`
|
||||||
modem.Authentication.Password = *opts.Password
|
Password string `json:"password,omitempty"`
|
||||||
}
|
}{}
|
||||||
|
if opts.Apn != nil {
|
||||||
if opts.Username != nil {
|
modem.Authentication.Apn = *opts.Apn
|
||||||
modem.Authentication.Username = *opts.Username
|
}
|
||||||
|
if opts.Type != nil {
|
||||||
|
modem.Authentication.Type = *opts.Type
|
||||||
|
}
|
||||||
|
if opts.Username != nil {
|
||||||
|
modem.Authentication.Username = *opts.Username
|
||||||
|
}
|
||||||
|
if opts.Password != nil {
|
||||||
|
modem.Authentication.Password = *opts.Password
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := o.PostModem(ctx, modem); err != nil {
|
if _, err := o.PostModem(ctx, modem); err != nil {
|
||||||
|
Reference in New Issue
Block a user