Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/nyc/c4q/ramonaharrison/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void main(String[] args) {
//myBot.sendMessage("Hello, world!");

// Post a pineapple photo to the #bots channel
//myBot.sendMessage("http://weknowyourdreams.com/images/pineapple/pineapple-07.jpg");
// myBot.sendMessageToBotsChannel("http://www.troll.me/images/ancient-aliens-guy/testing-aliens-thumb.jpg");

}
}
156 changes: 138 additions & 18 deletions src/nyc/c4q/ramonaharrison/model/Attachment.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package nyc.c4q.ramonaharrison.model;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
* Created by Ramona Harrison
* on 8/26/16
Expand All @@ -13,27 +17,143 @@

public class Attachment {

// TODO: implement private fields for each of the following attachment JSON keys:
// "fallback"
// "color"
// "pretext"
// "author_name"
// "author_link"
// "author_icon"
// "title"
// "title_link"
// "text"
// "fields"
// "image_url"
// "thumb_url"
// "footer"
// "footer_icon"
// "ts"
// TODO: implement private fields for each of the following attachment JSON keys: COMPLETED
private String fallback;
private String color;
private String pretext;
private String authorName;
private String authorIcon;
private String title;
private String titleLink;
private String text;
private List<Field> fields;
private String imageUrl;
private String thumbUrl;
private String footer;
private String footerIcon;
private long ts;



public Attachment(JSONObject json) {
// TODO: parse an attachment from the incoming json
// TODO: parse an attachment from the incoming json: COMPLETED

if(json.containsKey("fallback")){
this.fallback = (String) json.get("fallback");
}

if (json.containsKey("fields")){
JSONArray jsonFields = (JSONArray) json.get("fields");

this.fields = new ArrayList<Field>();
for (int i = 0; i < jsonFields.size(); i++) {
Field field = new Field((JSONObject) jsonFields.get(i));
}
}

if (json.containsKey("ts")) {
this.ts = (Long) json.get("ts");
}

if(json.containsKey("color")){
this.color = (String) json.get("color");
}

if(json.containsKey("pretext")){
this.pretext = (String) json.get("pretext");
}

if(json.containsKey("author_name")){
this.authorName = (String) json.get("author_name");
}
if(json.containsKey("author_icon")){
this.authorIcon = (String) json.get("author_icon");
}

if(json.containsKey("title")){
this.title = (String) json.get("title");
}

if(json.containsKey("title_link")){
this.titleLink = (String) json.get("title_link");
}

if(json.containsKey("text")){
this.text = (String) json.get("text");
}

if(json.containsKey("image_url")){
this.imageUrl = (String) json.get("image_url");
}

if(json.containsKey("thumb_url")){
this.thumbUrl = (String) json.get("thumb_url");
}

if(json.containsKey("footer_icon")){
this.footerIcon = (String) json.get("footer_icon");
}

if(json.containsKey("footer")){
this.footer = (String) json.get("footer");
}
}

// TODO add getters to access private fields
// TODO add getters to access private fields: COMPLETED
// getters
public String getFallback() {
return fallback;
}

public String getColor() {
return color;
}

public String getPretext() {
return pretext;
}

public String getAuthorName() {
return authorName;
}

public String getAuthorIcon() {
return authorIcon;
}

public String getTitle() {
return title;
}

public String getTitleLink() {
return titleLink;
}

public String getText() {
return text;
}

public List<Field> getFields() {
return fields;
}

public String getImageUrl() {
return imageUrl;
}

public String getThumbUrl() {
return thumbUrl;
}

public String getFooter() {
return footer;
}

public String getFooterIcon() {
return footerIcon;
}

public long getTs() {
return ts;
}
}
25 changes: 25 additions & 0 deletions src/nyc/c4q/ramonaharrison/model/Field.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package nyc.c4q.ramonaharrison.model;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

/**
* Created by jonathancolon on 9/11/16.
*/
public class Field {
private String title;
private String value;
private boolean isShort;

public Field(JSONObject json) {
if (json.containsKey("title")) {
this.title = (String) json.get("title");
}
if (json.containsKey("value")) {
this.title = (String) json.get("value");
}
if (json.containsKey("short")) {
this.isShort = (Boolean) json.get("short");
}
}
}
66 changes: 66 additions & 0 deletions src/nyc/c4q/ramonaharrison/model/Profile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package nyc.c4q.ramonaharrison.model;

import org.json.simple.JSONObject;

/**
* Created by jonathancolon on 9/11/16.
*/
public class Profile {
private String firstName;
private String lastName;
private String realName;
private String email;
private String skype;
private String phone;
private String image_24;
private String image_32;
private String image_48;
private String image_72;
private String image_192;
private String image_512;

public Profile(JSONObject json) {
if (json.containsKey("first_name")) {
this.firstName = (String) json.get("first_name");
}
if (json.containsKey("last_name")) {
this.lastName = (String) json.get("last_name");
}
if (json.containsKey("real_name")) {
this.realName = (String) json.get("real_name");
}
if (json.containsKey("email")) {
this.email = (String) json.get("email");
}
if (json.containsKey("skype")) {
this.skype = (String) json.get("skype");
}
if (json.containsKey("phone")) {
this.phone = (String) json.get("phone");
}
if (json.containsKey("image_24")) {
this.image_24 = (String) json.get("image_24");
}
if (json.containsKey("image_32")) {
this.image_32 = (String) json.get("image_32");
}
if (json.containsKey("image_48")) {
this.image_48 = (String) json.get("image_48");
}
if (json.containsKey("image_72")) {
this.image_72 = (String) json.get("image_72");
}
if (json.containsKey("image_192")) {
this.image_192 = (String) json.get("image_192");
}
if (json.containsKey("image_512")) {
this.image_512 = (String) json.get("image_512");
}






}
}
Loading