Skip to content

Commit ff0ffb4

Browse files
committed
2 parents 103e816 + fd5d44a commit ff0ffb4

17 files changed

+172
-16
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Messaging
2+
{
3+
using System;
4+
using System.Linq;
5+
using System.Text;
6+
using Newtonsoft.Json;
7+
using System.Collections.Generic;
8+
using System.Runtime.Serialization;
9+
using System.ComponentModel.DataAnnotations;
10+
11+
[DataContract]
12+
public partial class InvoiceRequest : IEquatable<InvoiceRequest>, IValidatableObject
13+
{
14+
public InvoiceRequest(List<Attachment> attachments = default(List<Attachment>), DateTime? coverageStartDate = default(DateTime?), DateTime? coverageEndDate = default(DateTime?))
15+
{
16+
this.Attachments = attachments;
17+
}
18+
19+
[DataMember(Name = "attachments", EmitDefaultValue = false)]
20+
public List<Attachment> Attachments { get; set; }
21+
22+
public override string ToString()
23+
{
24+
var sb = new StringBuilder();
25+
sb.Append("class InvoiceRequest {\n");
26+
sb.Append(" Attachments: ").Append(Attachments).Append("\n");
27+
sb.Append("}\n");
28+
return sb.ToString();
29+
}
30+
31+
public virtual string ToJson()
32+
{
33+
return JsonConvert.SerializeObject(this, Formatting.Indented);
34+
}
35+
36+
public override bool Equals(object input)
37+
{
38+
return this.Equals(input as InvoiceRequest);
39+
}
40+
41+
public bool Equals(InvoiceRequest input)
42+
{
43+
if (input == null)
44+
return false;
45+
46+
return
47+
(
48+
this.Attachments == input.Attachments ||
49+
this.Attachments != null &&
50+
this.Attachments.SequenceEqual(input.Attachments)
51+
);
52+
}
53+
54+
public override int GetHashCode()
55+
{
56+
unchecked // Overflow is fine, just wrap
57+
{
58+
int hashCode = 41;
59+
if (this.Attachments != null)
60+
hashCode = hashCode * 59 + this.Attachments.GetHashCode();
61+
return hashCode;
62+
}
63+
}
64+
65+
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
66+
{
67+
yield break;
68+
}
69+
}
70+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Messaging
2+
{
3+
using System;
4+
using System.Text;
5+
using Newtonsoft.Json;
6+
using System.Collections.Generic;
7+
using System.Runtime.Serialization;
8+
using System.ComponentModel.DataAnnotations;
9+
10+
[DataContract]
11+
public partial class InvoiceResponse : IEquatable<InvoiceResponse>, IValidatableObject
12+
{
13+
public InvoiceResponse(ErrorList errors = default(ErrorList))
14+
{
15+
this.Errors = errors;
16+
}
17+
18+
public InvoiceResponse()
19+
{
20+
this.Errors = default(ErrorList);
21+
}
22+
23+
[DataMember(Name = "errors", EmitDefaultValue = false)]
24+
public ErrorList Errors { get; set; }
25+
26+
public override string ToString()
27+
{
28+
var sb = new StringBuilder();
29+
sb.Append("class InvoiceResponse {\n");
30+
sb.Append(" Errors: ").Append(Errors).Append("\n");
31+
sb.Append("}\n");
32+
return sb.ToString();
33+
}
34+
35+
public virtual string ToJson()
36+
{
37+
return JsonConvert.SerializeObject(this, Formatting.Indented);
38+
}
39+
40+
public override bool Equals(object input)
41+
{
42+
return this.Equals(input as InvoiceResponse);
43+
}
44+
45+
public bool Equals(InvoiceResponse input)
46+
{
47+
if (input == null)
48+
return false;
49+
50+
return
51+
(
52+
this.Errors == input.Errors ||
53+
(this.Errors != null &&
54+
this.Errors.Equals(input.Errors))
55+
);
56+
}
57+
58+
public override int GetHashCode()
59+
{
60+
unchecked
61+
{
62+
int hashCode = 41;
63+
if (this.Errors != null)
64+
hashCode = hashCode * 59 + this.Errors.GetHashCode();
65+
return hashCode;
66+
}
67+
}
68+
69+
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
70+
{
71+
yield break;
72+
}
73+
}
74+
}

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/AvailableValueAddedServiceGroupList.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of value-added services available for a shipping service offering.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class AvailableValueAddedServiceGroupList : List<AvailableValueAddedServiceGroup> {
1515

1616
/// <summary>
@@ -32,5 +32,5 @@ public override string ToString() {
3232
return JsonConvert.SerializeObject(this, Formatting.Indented);
3333
}
3434

35-
}
35+
}
3636
}

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/ChargeList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of charges based on the shipping service charges applied on a package.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class ChargeList : List<ChargeComponent> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/IneligibleRateList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of ineligible shipping service offerings.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class IneligibleRateList : List<IneligibleRate> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/ItemList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of items.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class ItemList : List<Item> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/PackageDocumentDetailList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of post-purchase details about a package that will be shipped using a shipping service.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class PackageDocumentDetailList : List<PackageDocumentDetail> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/PackageDocumentList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of documents related to a package.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class PackageDocumentList : List<PackageDocument> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/PackageList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of packages to be shipped through a shipping service offering.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class PackageList : List<Package> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/PrintOptionList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of the format options for a label.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class PrintOptionList : List<PrintOption> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/RateList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of eligible shipping service offerings.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class RateList : List<Rate> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/RequestedValueAddedServiceList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// The value-added services to be added to a shipping service purchase.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class RequestedValueAddedServiceList : List<RequestedValueAddedService> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/SupportedDocumentSpecificationList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of the document specifications supported for a shipment service offering.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class SupportedDocumentSpecificationList : List<SupportedDocumentSpecification> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/TaxDetailList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
1010
/// <summary>
1111
/// A list of tax detail information.
1212
/// </summary>
13-
[DataContract]
13+
[CollectionDataContract]
1414
public class TaxDetailList : List<TaxDetail> {
1515

1616
/// <summary>

Source/FikaAmazonAPI/Services/ApiUrls.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ protected class MessaginApiUrls
177177
public static string GetAttributes(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/attributes";
178178
public static string CreateDigitalAccessKey(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/messages/digitalAccessKey";
179179
public static string CreateUnexpectedProblem(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/messages/unexpectedProblem";
180+
public static string SendInvoice(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/messages/invoice";
180181
}
181182
protected class EasyShip20220323
182183
{

Source/FikaAmazonAPI/Services/MessagingService.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,18 @@ public async Task<bool> CreateUnexpectedProblemAsync(string amazonOrderId, Creat
194194
return false;
195195
}
196196

197+
public bool SendInvoice(string amazonOrderId, InvoiceRequest invoiceRequest) =>
198+
Task.Run(() => SendInvoiceAsync(amazonOrderId, invoiceRequest)).ConfigureAwait(false).GetAwaiter().GetResult();
199+
public async Task<bool> SendInvoiceAsync(string amazonOrderId, InvoiceRequest invoiceRequest, CancellationToken cancellationToken = default)
200+
{
201+
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
202+
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", AmazonCredential.MarketPlace.ID));
203+
await CreateAuthorizedRequestAsync(MessaginApiUrls.SendInvoice(amazonOrderId), RestSharp.Method.Post, queryParameters, postJsonObj: invoiceRequest, cancellationToken: cancellationToken);
197204

198-
205+
var response = await ExecuteRequestAsync<InvoiceResponse>(RateLimitType.Messaging_CreateUnexpectedProblem, cancellationToken);
206+
if (response != null)
207+
return true;
208+
return false;
209+
}
199210
}
200-
}
211+
}

Source/FikaAmazonAPI/Services/ShippingServiceV2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public bool CancelShipment(string shipmentId) =>
1717
Task.Run(() => CancelShipmentAsync(shipmentId)).ConfigureAwait(false).GetAwaiter().GetResult();
1818
public async Task<bool> CancelShipmentAsync(string shipmentId, CancellationToken cancellationToken = default)
1919
{
20-
await CreateAuthorizedRequestAsync(ShippingApiV2Urls.CancelShipment(shipmentId), RestSharp.Method.Post, cancellationToken: cancellationToken);
20+
await CreateAuthorizedRequestAsync(ShippingApiV2Urls.CancelShipment(shipmentId), RestSharp.Method.Put, cancellationToken: cancellationToken);
2121
var response = await ExecuteRequestAsync<CancelShipmentResponse>(RateLimitType.ShippingV2_CancelShipment, cancellationToken);
2222
if (response != null)
2323
return true;

0 commit comments

Comments
 (0)