Skip to content

Commit

Permalink
added email to order update fields (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
atcdot authored Jan 10, 2020
1 parent b07d9f8 commit 56a6cf8
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions update-order-models.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type UpdateOrder struct {
DeliveryRecipientVATRate *string `xml:"DeliveryRecipientVATRate,attr"`
DeliveryRecipientVATSum *float64 `xml:"DeliveryRecipientVATSum,attr"`
RecipientName *string `xml:"RecipientName,attr"`
RecipientEmail *string `xml:"RecipientEmail,attr"`
Phone *string `xml:"Phone,attr"`
RecipientINN *string `xml:"RecipientINN,attr"`
DateInvoice *string `xml:"DateInvoice,attr"`
Expand Down
7 changes: 7 additions & 0 deletions update-order-req-builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ func (updateOrder *UpdateOrder) SetRecipientName(recipientName string) *UpdateOr
return updateOrder
}

//SetRecipientEmail Receiver's email for sending order status notifications and contacting in case of failed calls
func (updateOrder *UpdateOrder) SetRecipientEmail(recipientEmail string) *UpdateOrder {
updateOrder.RecipientEmail = &recipientEmail

return updateOrder
}

//SetPhone Receiver's phone
func (updateOrder *UpdateOrder) SetPhone(phone string) *UpdateOrder {
updateOrder.Phone = &phone
Expand Down
76 changes: 76 additions & 0 deletions update-order-req-builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,82 @@ func TestUpdateOrder_SetRecipientName(t *testing.T) {
}
}

func TestUpdateOrder_SetRecipientEmail(t *testing.T) {
type fields struct {
Number *string
DispatchNumber *int
DeliveryRecipientCost *float64
DeliveryRecipientVATRate *string
DeliveryRecipientVATSum *float64
RecipientName *string
RecipientEmail *string
Phone *string
RecipientINN *string
DateInvoice *string
Passport *Passport
Address *Address
DeliveryRecipientCostAdv *DeliveryRecipientCostAdv
Package *OrderPackage
}
type args struct {
recipientEmail string
}
tests := []struct {
name string
fields fields
args args
want *UpdateOrder
}{
{
name: "set",
fields: fields{
RecipientEmail: nil,
},
args: args{
recipientEmail: "[email protected]",
},
want: &UpdateOrder{
RecipientEmail: strLink("[email protected]"),
},
},
{
name: "modify",
fields: fields{
RecipientEmail: strLink("[email protected]"),
},
args: args{
recipientEmail: "[email protected]",
},
want: &UpdateOrder{
RecipientEmail: strLink("[email protected]"),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
updateOrder := &UpdateOrder{
Number: tt.fields.Number,
DispatchNumber: tt.fields.DispatchNumber,
DeliveryRecipientCost: tt.fields.DeliveryRecipientCost,
DeliveryRecipientVATRate: tt.fields.DeliveryRecipientVATRate,
DeliveryRecipientVATSum: tt.fields.DeliveryRecipientVATSum,
RecipientName: tt.fields.RecipientName,
RecipientEmail: tt.fields.RecipientEmail,
Phone: tt.fields.Phone,
RecipientINN: tt.fields.RecipientINN,
DateInvoice: tt.fields.DateInvoice,
Passport: tt.fields.Passport,
Address: tt.fields.Address,
DeliveryRecipientCostAdv: tt.fields.DeliveryRecipientCostAdv,
Package: tt.fields.Package,
}
if got := updateOrder.SetRecipientEmail(tt.args.recipientEmail); !reflect.DeepEqual(got, tt.want) {
t.Errorf("UpdateOrder.SetRecipientEmail() = %v, want %v", got, tt.want)
}
})
}
}

func TestUpdateOrder_SetPhone(t *testing.T) {
type fields struct {
Number *string
Expand Down

0 comments on commit 56a6cf8

Please sign in to comment.