Commit Graph

51 Commits

Author SHA1 Message Date
Lehonti Ramos d46527d143 Added readonly to fields that are never modified (#2759)
Co-authored-by: Lehonti Ramos <john@doe>
Co-authored-by: Keegan Campbell <me@kfcampbell.com>
2023-08-11 09:53:51 -07:00
Next Turn fd3b1c7e79 Add support for ReleaseEvent payload (#2170) 2020-04-11 20:44:57 -03:00
Brendan Forster e9516bb6c1 bugfix: improve fallback when StringEnum encounters null value (#2156) 2020-03-17 15:09:15 -03:00
Jose de Jesus Medina 5eb9f06b24 Fix typos in comments (#2040) 2019-10-30 13:51:20 -03:00
Guillaume Mouron 47c38bfd8e Add support for CreateEventPayload and DeleteEvent payload (#1646) (#1932) 2019-01-31 20:37:00 +10:00
Ryan Gribble c5d5df5b08 Implement Check Runs API (#1847)
* Add CheckRunEventPayload

* add CheckRunEventPayload into all the right places

* forgot integration tests for RepositoryId methods (+1 squashed commits)

Squashed commits:

[b2445bf3] Implement Create CheckRun methods for normal and observable clients including unit and integration tests and xmldoc comments

* Implement Update CheckRun method
Refactored NewCheckRun to inherit CheckRunUpdate since they share all fields except HeadSha

* Implement GetAllForReference method

* Implement GetAllForCheckSuite method

* tweak XmlDoc to match github documentation

* Implement Get method

* Implement GetAllAnnotations
Moved CheckRunAnnotation model from Request to Common and added a parameterless ctor, since it is now a response model as well as a request model

* Split common CheckRunAnnotation model into separate response and request models due to different field and ctor requirements
Rename other CheckRun request sub classes to be consistent with NewCheckRunAnnotation (eg NewCheckRunOutput, NewCheckRunImage, etc)

* add title field back into CheckRunAnnotation

* fix up XmlDocs

* fix mutable response property - hooray for convention tests!
2018-07-19 08:29:12 +10:00
Ryan Gribble 4df21a61de Implement Check Suites API (#1846)
* Check run request models

* Check Run response models

* Check run clients

* Check run ApiUrls and AcceptHeaders

* Pack it all together for now

* Add missing accept headers to connection calls

* Standardize class definitions

* Standardize function names

* Merge ICheckRunAnnotationsClient into ICheckRunsClient

* Properly organize clients

* Cleanup CheckRun response model

* Fix slug check run urls

* Add checks installation permission

* Use StringEnums where appropriate

* Cleanup check run output models

* Flesh out CheckSuite model

* Delete CheckRunsList

* Remove a sealed, fix some line endings

* Adding check suite models

* Skeleton check suite client implementation

* Add check suite ApiUrls

* Flesh out check suites client

* Add parameterless CheckRun constructor

* Add DebuggerDisplay to checks models

* Add observable checks interfaces

* Add return values to POST and PATCH check clients

* Fix some check suite client return values

* Skeleton reactive checks implementation

* Implement observable checks clients

* Remove rogue tabs

* Add CheckSuiteEventPayload

* Add CheckRunEventPayload

* Add DebuggerDisplay attributes to checks API payloads

* Properly nullables check suite/run conclusion

* Add CheckSuiteEventTests

* Fix checks client accessor naming issues

* Add missing Text field to CheckRunOutput

* Marks CheckRunUpdate's conclusion as nullable

* Fix reactive checks client naming

* Today I learned DateTimeOffset is a struct

Makes CheckRunUpdate's DateTimeOffsets nullable

* Modify check clients to put slug version before repo id version

* Add nullable to CheckRun.CompletedAt

* Implement parameterless ICheckRunsClient.GetAllForReference and GetAllForCheckSuite

* Add missing RequestParameters base to CheckSuiteRequest

* Implement checks API GetAll methods

* Bring parity to Reactive checks clients

* fix project settings to get GitHubApp helper working again

* remove un-needed InstallationId setting - provide helper method to find installation based on owner

* fix up request object ctors based on required/optional parameters

* fix up request object ctors based on required/optional parameters

* add some initial integration tests for CheckSuites and CheckRuns including some helper methods

* Add test for Request CheckSuite
Fix Request CheckSuite to use correct Uri
Fix Request CheckSuite return type as it doesnt return an object
Fix CheckSuiteTriggerRequest ctor to make required fields mandatory

* simplify Get CheckSuite test to not require as much data setup

* Add test for CheckSuite GetAllForReference

* Add test for CheckSuite UpdatePreferences

* rename response models

* rename CheckSuitesList to CheckSuitesResponse and use as response to the GetAll calls

* Fix tests

* Fix observable

* fix model convention tests

* remove CheckRuns so we can focus only on CheckSuites for now

* naming things is hard

* oh so many unit tests for CheckSuites methods

* make client mockable

* Fix issue with .Max() when no results returned

* fix request parameter names

* add Xml doc comments

* Add XmlDoc comments to request/common model objects

* rename class to match usage

* tidy ups

* xmldoc for observable clients

* fix method order

* add observable unit tests and get them passing

* Add Observable unit tests and get them passing

* add observable integration tests

* tidy up ApiUrl method name

* whitespace/using tidy ups

* Ensure CheckSuiteEventPayload class is handled in deserializer and add to activity test

* add response model XmlDoc comments

* missed one xmldoc

* add xmldoc to NewCheckSuite request and remove HeadBranch property as it doesnt exist anymore

* add some extra check suites integration tests
2018-07-14 20:01:41 +10:00
Itai Bar-Haim 4e804f61a6 Prefer using nameof(x) over literal "x" (#1781)
* updated XML docs and added some missing bits.

* prefer nameof(x) over literal "x"
2018-03-07 20:43:10 +10:00
Jordan Brown 3ec01bd05a Adds PullRequestReviewEventPayload (#1767)
* Adds PullRequestReviewEventPayload

* Remove random A
2018-02-25 20:18:26 +10:00
Ryan Gribble c4774ffaf0 Release v0.29 - This Looks Serious (TLS) (#1765)
* Add release notes

* Fix failing integration test

* Run FormatCode build task to tidy up whitespace

* Remove "UnkownUser" from release notes contributors
2018-02-18 20:36:49 +10:00
Ryan Gribble 41b4059c11 Deserializer should handle nullable StringEnum<T> (#1760)
* add deserializer tests for nullable enums, StringEnum and nullable StringEnum properties

* Fix deserializing nullable structs by using the underlying type when nullable

* StringEnum<T> should behave like an enum, returning default(T) when it is uninitialised/null/blank

* Don't allow null to be passed into StringEnum ctor - if it needs to be null then it should be declared as nullable

* fix expected json

* move logic to determine if property is a StringEnum<T> into helper function

* serializer needs to treat StringEnum<T> specially by serializing the enum value according to existing serializer strategy (parameter attributes and so on)

* remove fallback to default(T)

* add test to assert ctor throws exception when null passed in

* remove test for default(T) fallback behaviour

* Fix exception in serializer test - StringEnum property must be initialized otherwise an exception is thrown when attempting to serialize

* Dont allow empty strings either
2018-02-16 20:12:44 +10:00
Dave Glick bf0688517f Refactors GitHubSerializerStrategy to be thread-safe (#1683) (#1748) 2018-01-31 22:06:37 +10:00
Itai Bar-Haim 9a29aa4f2f Add support for StatusEventPayload (#1732)
* added support for StatusEventPayload

* Added test for StatusEventPayload and fixed serializer to return that event payload type.
2018-01-09 12:38:38 +10:00
Kristian Hellang 5ee4d64046 Add StringEnum to handle unknown enum values returned from API (#1595)
* Added StringEnum<TEnum>

* Added tests

* Make sure the serializer can work with StringEnum

* Use StringEnum for EventInfo.Event

* Add convention test to assert that all Response models use StringEnum<> to wrap enum properties

* Add Stringnum<> to all response types failing convention test

* Handle StringEnum to Enum conversion when Issue response model populates IssueUpdate request model

* Fix unit test

* Refactor SimpleJsonSerializer to expose the DeserializeEnum strategy so it can be used in StringEnum class

* Need to expose/use SerializeEnum functionality too, so we use the correct string representation of enum values that have custom properties (eg ReactionType Plus1 to "+1")

* fix unit tests, since the string is now the "correct" upstream api value

* Add a couple of tests for the Enum serialize/deserialize when underscores, hyphens and custom property attributes are present

* Compare parsed values for equality

* add convention test to ensure enum members all have Parameter property set

* update test to cover implicit conversions too

* this test should work but fails at the moment due to magic hyphen removal in deserializer causing a one way trip from utf-8 to EncodingType.Utf8 with no way to get back

* (unsuccesfully) expand event info test to try to catch more cases of unknown event types

* fix broken integration test while im here

* Fixed build errors after .NET Core merge

* Value -> StringValue, ParsedValue -> Value

* Don't allow StringValue to be null

* Ignore enums not used in request/response models

* Added ParameterAttribute to almost all enum values

* Ignore Language enum

* Fix failing tests

* Fix milestone sort parameter and tests

* whitespace

* fix milestone unit tests

* Fix StringEnum.Equals ... This could've been embarrassing!

* Change SimpleJsonSerializer Enum handling to only use `[Parameter()]` attributes (no more magic removal of hyphen/underscores from strings)

* Tidy up this integration test while im here

* Only test request/response enums in convention test

* Keep skipping Language

* Remove unused method

* Remove excluded enum types

* Removed unnecessary ParameterAttributes

* Remove unused enum

* Add StringEnum test for string-comparison of two invalid values

* Bring back IssueCommentSort and use it in IssueCommentRequest

This reverts commit 38a4a291d1476ef8c992fe0f76956974b6f32a49.

* Use assembly instead of namespace for Octokit check

* Add failing test to reproduce the issue where only the first enum paramter/value was added to the cache

* Fix deserializer enum cache to include all enum members rather than only the first member encountered

* Use a static SimpleJsonSerializer in StringEnum

* Remove serializer instance in StringEnum

* Add some documentation on StringEnum<TEnum>

* Fix parameter value to resolve failing integration test
2017-06-25 19:29:57 +10:00
Ryan Gribble 3c818934b8 Release v0.24 - A Sight For Sore Eyes (#1539)
* Add release notes and bump version to 0.24

* run "build FormatCode" to fix up whitespace/formatting issues

* Fix failing Ssh key tests due to "validation exception".  This key must be in use on github (under another user, most likely from these tests failing).  Changed to a new SSH key and tweaked tests to reduce chance of a key being created and not destroyed

* Assignee and Assignees cant both be specified on NewIssue.  We missed this one in the PR.  Marked Assignee as [Obsolete] and fixed tests to use Assignees

* Fix a couple of Reactions tests that were calling the wrong client methods

* Fix timeline tests - looks like the response class has changed shape a bit, it now has an Issue object in the payload and Id field isnt present (leaving Id field there in case other timeline events do use it)

* Fix some following tests that require the test user to follow more than 1 other user

* Unskip these Event tests now because apparently they work!

* add breaking changes notes

* Update ApiErrorMessageSafe to return null for empty and whitespace strings (#1540)

* return null if ApiError.Message is empty or whitespace

* Uncomment test, which now passes

* update release notes to include PR1540

* Add "Bot" AccountType, was causing a deserialization exception when running the integration test "SearchForExcludedLanguage" (#1541)

* Update to include PR1541

* add bullets to make release notes easier to read

* markup additional code mentions in notes

* Fix grammar

fields => field
2017-01-17 18:56:55 +10:00
Martin Scholz d650f2a406 [WIP] deserialization 2016-06-27 09:15:26 +02:00
Martin Scholz 63629d5029 add method to check attributes 2016-06-24 10:36:00 +02:00
Martin Scholz 844be5586d revert NewReaction client and fix SimpleJsonSerializer 2016-06-23 09:45:22 +02:00
Martin Scholz d700433440 change NewReaction
change NewReaction to inherit from RequestParamaters. Change all
reaction clients.
2016-06-22 13:02:54 +02:00
Martin Scholz 4c05be81d4 fix deserialization of enums with custom attributes 2016-06-22 11:44:20 +02:00
Martin Scholz c1a16ffc74 get customAttribute for netfx 2016-06-21 19:40:16 +02:00
Martin Scholz ac14c5e1a2 fix serialization of enum values 2016-06-21 18:34:27 +02:00
Ryan Gribble 3b74250abf - Add unit tests to assert expected behaviour when deserializing strings containing hyphens (and underscores for good measure) into a string and List<string> objects
- Fix failing List<string> test by removing the seemingly redundant line in the deserializer
2016-02-05 21:04:02 +10:00
Brendan Forster 80719c0033 aaaand format the code 2015-11-04 13:38:51 -08:00
Haacked 0b13411ef5 🎨 Remove unnecessary assignment 2015-08-04 21:20:13 -07:00
Haacked eb5d14cfdc Organize usings and remove unused 2015-08-04 21:12:37 -07:00
David Martin c55c70f284 updated event type names 2015-03-07 18:00:22 +00:00
David Martin 2ee42b553f removed unused references, fixed namespaces, added 'forkee' to customdictionary.xml 2015-03-04 23:29:21 +00:00
David Martin ecc3aeec62 added more payload types and tests 2015-03-02 22:15:13 +00:00
David Martin 3490f86789 added payload to activity, implemented commit_comment type, and updated json serializer strategy (with test) 2015-03-02 18:19:59 +00:00
Jan Ove Skogheim 46e572131f Ignore underscores when parsing enums under deserialization. 2015-02-25 22:36:18 +01:00
Haacked 641b03de41 Improve support for base64 strings 2015-01-02 01:14:17 -08:00
Haacked 543d1bb863 Add support for deserializing non-public members
But only ones with ParameterAttribute applied.
2015-01-02 01:14:16 -08:00
Haacked 47e67e9382 Reflection abstractions to reduce code duplication 2015-01-02 01:14:15 -08:00
Haacked 83bc99256a Add attribute to serialize strings as base64 encoded 2015-01-02 01:14:12 -08:00
Matt G. Ellis d0dcbe8fb6 Allow [Parameter] to control JSON Field Names.
Previously, SimpleJsonSerializer.MapClrMemberNameToJsonFieldName
special cased the name "Links" since while that was the name of the
property in the object model, in JSON "_links" was used instead.

It turns out that there was an additional problem, where GitReference
wants to expose as Repository, but the name in JSON responses is
"repo".  Instead of simply adding another special case to
MapClrMemberNameToJsonFieldName, we update the implementation of the
serializer to allow [Parameter(Key = "some_name")] to denote what name
we'd like to use for the field in the JSON object when we serialize.
2014-11-17 23:55:37 -08:00
Brendan Forster 1edd8c377f patch the serializer for our silly OAuth response format 2014-10-06 16:05:44 -02:00
Brendan Forster a19d2feb21 implement a lookup of the fields/properties which should serialize null values 2014-07-08 12:50:32 +09:30
Brendan Forster 2e47369b9b use opt-in attributes to indicate when a null property should be sent 2014-07-08 09:34:12 +09:30
Haacked aaa010d790 Special case JSON _links property.
For some reason, the List Feeds http://developer.github.com/v3/activity/feeds/#list-feeds
API response has a field that starts with an underscore. This also occurs in
the Review Comments API: http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
and in the Contents API. http://developer.github.com/v3/repos/contents/#get-the-readme

This commit special cases that one field so we can use the expected CLR
property name. I couldn't find a case where a
JSON response doesn't prefix "links" with an underscore.

Related to #386
2014-02-20 09:34:45 -08:00
Haacked 9257ba4f41 Some code style cleanup 2014-02-20 09:23:56 -08:00
Brendan Forster 09a0ea6c56 updated SimpleJson to 0.30.0 2014-01-23 14:49:35 -08:00
pltaylor cf31e1da02 code review cleanups. 2013-11-13 19:53:52 -05:00
pltaylor 04349e6172 Strip '-' from strings coming in to be de-serialized. 2013-11-07 14:26:01 -05:00
Brendan Forster b3ceb1d661 we should deserialize Urls in a specific way 2013-11-04 17:58:42 +11:00
Haacked ad210cecc7 Implement IssuesClient and interface
This required updating our serialization strategy so we handle enums
better.
2013-10-23 14:46:19 -07:00
half-ogre b437060b7d move reflection stuff to .Internal namespace 2013-10-08 15:16:27 -07:00
half-ogre 6f3fa81789 move internal stuff to .Internal namespace 2013-10-08 15:14:06 -07:00
half-ogre 0444f8630a omit null values from serialized objects 2013-10-07 17:06:20 -07:00
Haacked 91b5449ddd Removed fluent assertions 2013-09-23 17:41:04 -07:00