ringcentral / RingCentral.Net

RingCentral SDK for .NET
MIT License
19 stars 26 forks source link

Use Properties instead of Fields #25

Closed TonyValenti closed 3 years ago

TonyValenti commented 4 years ago

It seems that the data in RingCentral is all stored as fields. In .NET, it is standard practice to use properties instead.

For example:

public class GetMessageList {
        public string uri;

        public GetMessageInfoResponse[] records;

        public MessagingNavigationInfo navigation;

        public MessagingPagingInfo paging;
    }

becomes:

public class GetMessageList {
        public string Uri {get; set;} ;

        public GetMessageInfoResponse[] Records {get; set;}

        public MessagingNavigationInfo Navigation {get; set;}

        public MessagingPagingInfo Paging {get; set;}
    }
tylerlong commented 4 years ago

I get your point and I agree with you. I will likely change this in next major version.

Those definitions classes are auto generated from swagger spec. So they purely serves as JSON serialization/deserialization purpose. So they probably don't need those benefits properties have over fields.

JeffEmery commented 3 years ago

The default ASP.NET JSON model binder doesn't work with fields. The following produces null values in the message variable.

public async Task<IActionResult> Receive([FromBody] InstantMessageEvent message)

I pasted the WebHook JSON "as classes" which creates properties and replaced InstantMessageEvent with the custom class and the model binder works.

tylerlong commented 3 years ago

@JeffEmery Thanks for the information and it is very useful.

tylerlong commented 3 years ago

Release 5.0.0-beta4