package com.google.graphgeckos.dashboard.datatypes;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.cloud.Timestamp;
import java.util.Map;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GitHubData {

  private String branch = "master";

  private String commitHash;

  private String timestamp;

  private String repositoryLink;

  @JsonProperty("author")
  private void unPackAuthor(Map<String, ?> author) {
    this.timestamp = author.get("date").toString();
  }

  @JsonProperty("sha")
  private void unpackCommitHash(String sha) {
    this.commitHash = sha;
  }

  /**
   * Extracts link to the working repository (html_url field value) from the data of the repository field.
   * @param repository representation of the repository field of the GitHub API request json.
   */
  @JsonProperty("html_url")
  private void extractRepositoryLink(String url) {
    repositoryLink = url;
  }

  public GitHubData() {}

  public GitHubData(String commitHash, Timestamp timestamp, String branch) {
    this.commitHash = commitHash;
    this.timestamp = timestamp.toString();
    this.branch = branch;
  }

  public GitHubData(String commitHash, String branch) {
    this.commitHash = commitHash;
    this.branch = branch;
  }

  /**
   * Returns name of the Git branch, where the tested changes were made.
   */
  public String getBranch() {
    return branch;
  }

  /**
   * Returns Git commit hash of the last commit.
   */
  public String getCommitHash() {
    return commitHash;
  }

  /**
   * Returns time of when the commit was pushed.
   */
  public String getTimestamp() {
    return timestamp;
  }

  /**
   * Returns link to the Git repository, where the last commit was made.
   */
  public String getRepositoryLink() {
    return repositoryLink;
  }

}

@@ -421,16 +421,1142 @@
 yLink;%0A%0A
+  /**%0A   * Extracts commit id (also known as commit hash) and timestamp nested fields from the data of the head_commit%0A   * field.%0A   * @param headCommit representation of the head_commit field of the GitHub API request json.%0A   */%0A  @JsonProperty(%22head_commit%22)%0A  private void unpackHeadCommit(Map%3CString, Object%3E headCommit) %7B%0A    commitHash = headCommit.get(%22id%22).toString();%0A    timestamp = headCommit.get(%22timestamp%22).toString();%0A  %7D%0A%0A  /**%0A   * Extracts link to the working repository (html_url field value) from the data of the repository field.%0A   * @param repository representation of the repository field of the GitHub API request json.%0A   */%0A  @JsonProperty(%22repository%22)%0A  private void extractRepositoryLink(Map%3CString, Object%3E repository) %7B%0A    repositoryLink = repository.get(%22html_url%22).toString();%0A  %7D%0A%0A  /**%0A   * Extracts the name of the branch from the reference.%0A   * @param ref Git reference.%0A   */%0A  @JsonProperty(%22ref%22)%0A  private void extractBranch(String ref) %7B%0A    String%5B%5D refComponents = ref.split(%22/%22);%0A    branch = refComponents%5BrefComponents.length - 1%5D;%0A  %7D%0A%0A  // Properties for the GitHubClient%0A
   @JsonP
@@ -1573,16 +1573,16 @@
 uthor%22)%0A
-
   privat
@@ -1682,17 +1682,19 @@
 ();%0A  %7D%0A
+  
 %0A
-
   @JsonP
@@ -1781,25 +1781,26 @@
  = sha;%0A  %7D%0A
+ 
 %0A
-
   /**%0A   * E
@@ -1788,32 +1788,33 @@
 %0A  %7D%0A %0A  /**%0A   
+ 
 * Extracts link 
@@ -1896,32 +1896,33 @@
 itory field.%0A   
+ 
 * @param reposit
@@ -1988,32 +1988,33 @@
 I request json.%0A
+ 
    */%0A  @JsonPro

Add properties to GitHubData for GitHubClient