-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
195 additions
and
98 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
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 |
---|---|---|
@@ -1 +1 @@ | ||
1.0.9 | ||
1.0.11 |
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
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
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
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
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
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,63 @@ | ||
package com.stripe.model; | ||
|
||
import java.util.Map; | ||
|
||
import com.stripe.exception.StripeException; | ||
import com.stripe.net.APIResource; | ||
|
||
public class Event extends APIResource { | ||
String id; | ||
String type; | ||
Boolean livemode; | ||
Long created; | ||
EventData data; | ||
|
||
public static Event retrieve(String id) throws StripeException { | ||
return request(RequestMethod.GET, instanceURL(Event.class, id), null, Event.class); | ||
} | ||
|
||
public static EventCollection all(Map<String, Object> params) throws StripeException { | ||
return request(RequestMethod.GET, classURL(Event.class), params, EventCollection.class); | ||
} | ||
|
||
public EventData getData() { | ||
return data; | ||
} | ||
|
||
public void setData(EventData data) { | ||
this.data = data; | ||
} | ||
|
||
public Long getCreated() { | ||
return created; | ||
} | ||
|
||
public void setCreated(Long created) { | ||
this.created = created; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String name) { | ||
this.type = name; | ||
} | ||
|
||
public Boolean getLivemode() { | ||
return livemode; | ||
} | ||
|
||
public void setLivemode(Boolean livemode) { | ||
this.livemode = livemode; | ||
} | ||
|
||
} |
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
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,24 @@ | ||
package com.stripe.model; | ||
|
||
import java.util.Map; | ||
|
||
public class EventData extends StripeObject { | ||
Map<String, Object> previousAttributes; | ||
StripeObject object; | ||
|
||
public Map<String, Object> getPreviousAttributes() { | ||
return previousAttributes; | ||
} | ||
|
||
public void setPreviousAttributes(Map<String, Object> previousAttributes) { | ||
this.previousAttributes = previousAttributes; | ||
} | ||
|
||
public StripeObject getObject() { | ||
return object; | ||
} | ||
|
||
public void setObject(StripeObject object) { | ||
this.object = object; | ||
} | ||
} |
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,49 @@ | ||
package com.stripe.model; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonDeserializer; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParseException; | ||
import com.google.gson.reflect.TypeToken; | ||
import com.stripe.net.APIResource; | ||
|
||
public class EventDataDeserializer implements JsonDeserializer<EventData> { | ||
|
||
static Map<String, Class> objectMap = new HashMap<String, Class>(); | ||
static { | ||
objectMap.put("charge", Charge.class); | ||
objectMap.put("discount", Discount.class); | ||
objectMap.put("customer", Customer.class); | ||
objectMap.put("invoice", Invoice.class); | ||
objectMap.put("invoiceitem", InvoiceItem.class); | ||
objectMap.put("plan", Plan.class); | ||
objectMap.put("subscription", Subscription.class); | ||
objectMap.put("token", Token.class); | ||
} | ||
|
||
public EventData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) | ||
throws JsonParseException { | ||
EventData eventData = new EventData(); | ||
JsonObject jsonObject = json.getAsJsonObject(); | ||
for(Map.Entry<String, JsonElement> entry: jsonObject.entrySet()) { | ||
String key = entry.getKey(); | ||
JsonElement element = entry.getValue(); | ||
if("previous_attributes".equals(key)) { | ||
Type typeOfPrevAttrs = new TypeToken<Map<String, Object>>(){}.getType(); | ||
eventData.setPreviousAttributes( | ||
(Map<String, Object>) APIResource.gson.fromJson(element, typeOfPrevAttrs)); | ||
} else if ("object".equals(key)) { | ||
String type = element.getAsJsonObject().get("object").getAsString(); | ||
Class<StripeObject> cl = objectMap.get(type); | ||
StripeObject object = APIResource.gson.fromJson(entry.getValue(), cl); | ||
eventData.setObject(object); | ||
} | ||
} | ||
return eventData; | ||
} | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.