bunq / sdk_csharp

C# SDK for bunq API
MIT License
35 stars 22 forks source link

additional_transaction_information does not exist on Event object #133

Open Tieno opened 4 years ago

Tieno commented 4 years ago

Steps to reproduce:

  1. use SDK
  2. retrieve events via Event.List()

What should happen:

  1. Have access to additional_transaction_information image

What happens:

  1. Property does not exist on BunqSdk/Model/Generated/Endpoint/Event.cs

SDK version and environment

It's also not documented @ https://doc.bunq.com/#/event/List_all_Event_for_User

image

Tieno commented 4 years ago

here's a quick and dirty fix(up)

public class EventFixup : Event { [JsonProperty(PropertyName = "additional_transaction_information")] public AdditionalTransactionInformationDto AdditionalTransactionInformation { get; set; } public static BunqResponse<List> List(IDictionary<string, string> urlParams = null, IDictionary<string, string> customHeaders = null) { if (urlParams == null) urlParams = new Dictionary<string, string>(); if (customHeaders == null) customHeaders = new Dictionary<string, string>();

        var apiClient = new ApiClient(GetApiContext());
        var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, DetermineUserId()), urlParams,
            customHeaders);

        return FromJsonList<EventFixup>(responseRaw, "Event");
    }

    public static BunqResponse<EventFixup> Get(int eventId, IDictionary<string, string> customHeaders = null)
    {
        if (customHeaders == null) customHeaders = new Dictionary<string, string>();

        var apiClient = new ApiClient(GetApiContext());
        var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, DetermineUserId(), eventId),
            new Dictionary<string, string>(), customHeaders);

        return FromJson<EventFixup>(responseRaw, "Event");
    }

    public partial class AdditionalTransactionInformationDto
    {
        [JsonProperty("category")]
        public string Category { get; set; }

        [JsonProperty("category_translated")]
        public string CategoryTranslated { get; set; }

        [JsonProperty("name")]
        public string Name { get; set; }

        [JsonProperty("email")]
        public string Email { get; set; }

        [JsonProperty("phone_number")]
        public string PhoneNumber { get; set; }

        [JsonProperty("url")]
        public Uri Url { get; set; }

        [JsonProperty("geolocation")]
        public Geolocation Geolocation { get; set; }

        [JsonProperty("avatar")]
        public Avatar Avatar { get; set; }

        [JsonProperty("address")]
        public Address Address { get; set; }

        [JsonProperty("hash_counterparty")]
        public string HashCounterparty { get; set; }
    }

    public partial class Address
    {
        [JsonProperty("street")]
        public string Street { get; set; }

        [JsonProperty("house_number")]
        public string HouseNumber { get; set; }

        [JsonProperty("postal_code")]
        public string PostalCode { get; set; }

        [JsonProperty("city")]
        public string City { get; set; }

        [JsonProperty("country")]
        public string Country { get; set; }

        [JsonProperty("province")]
        public string Province { get; set; }

        [JsonProperty("extra")]
        public string Extra { get; set; }

        [JsonProperty("mailbox_name")]
        public string MailboxName { get; set; }
    }

    public partial class Avatar
    {
        [JsonProperty("uuid")]
        public Guid Uuid { get; set; }

        [JsonProperty("image")]
        public List<Image> Image { get; set; }

        [JsonProperty("anchor_uuid")]
        public object AnchorUuid { get; set; }
    }

    public partial class Image
    {
        [JsonProperty("attachment_public_uuid")]
        public Guid AttachmentPublicUuid { get; set; }

        [JsonProperty("height")]
        public long Height { get; set; }

        [JsonProperty("width")]
        public long Width { get; set; }

        [JsonProperty("content_type")]
        public string ContentType { get; set; }
    }

    public partial class Geolocation
    {
        [JsonProperty("latitude")]
        public decimal Latitude { get; set; }

        [JsonProperty("longitude")]
        public decimal Longitude { get; set; }

        [JsonProperty("altitude")]
        public decimal Altitude { get; set; }

        [JsonProperty("radius")]
        public decimal Radius { get; set; }
    }
}

`