-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from SEbbaDK/server-writing
Added contribution class and contribution post endpoint
- Loading branch information
Showing
2 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Contribution | ||
property contribution_id : Nil | Int64 | ||
property user_id : Int64 | ||
property type : Int64 | ||
property changeset : Int64 | ||
property score : Int64 | ||
property date_time : Time | ||
|
||
def initialize ( | ||
@user_id, | ||
@type, | ||
@changeset, | ||
@score, | ||
@date_time, | ||
@contribution_id = nil, | ||
) | ||
end | ||
|
||
def self.from_json (json_obj) | ||
#contribution_id: json_obj["contributionid"]?.as(Int64 | Nil), | ||
contribution = Contribution.new( | ||
user_id:json_obj["id"].as(Int64), | ||
type: json_obj["type"].as(Int64), | ||
changeset:json_obj["changeset"].as(Int64), | ||
score: json_obj["score"].as(Int64), | ||
date_time: Time.parse_iso8601(json_obj.["datetime"].as(String)), | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters