Skip to content

Commit

Permalink
Merge pull request #79 from cryptohopper/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
canerten authored May 15, 2023
2 parents 8e780bf + ab10afa commit bcb1390
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cryptohopper.android.sdk.SharedModels.ConfigModels.HopperAPIHttpMethod

class HopperAPICopyBotCreateHopperRequest : HopperAPIRequest<HopperAPIPurchaseResponse> {

constructor(copyBotMarketplaceId : String, paperTrading: Boolean, apiKey : String? , apiSecret : String? , apiPassphrase : String? , extraApiKey : String? , extraApiSecret : String? ) {
constructor(copyBotMarketplaceId : String, paperTrading: Boolean, apiKey : String? , apiSecret : String? , apiPassphrase : String? , extraApiKey : String? , extraApiSecret : String?,autoSync : Boolean = true, isSandbox : Boolean = false ) {
this.httpMethod = HopperAPIHttpMethod.POST
this.needsAuthentication = true
this.changeUrlPath("/app/mobile/iap")
Expand All @@ -17,6 +17,9 @@ class HopperAPICopyBotCreateHopperRequest : HopperAPIRequest<HopperAPIPurchaseRe
addBodyItem( "walletscrubber", "1")
addBodyItem( "autosync", "1")

if(autoSync){
addBodyItem("autosync","1")
}
if(paperTrading){
addBodyItem( "paper_trading", "1")
}else{
Expand All @@ -37,5 +40,8 @@ class HopperAPICopyBotCreateHopperRequest : HopperAPIRequest<HopperAPIPurchaseRe
if(extraApiSecret != null){
addBodyItem( "extra_api_secret", extraApiSecret)
}
if(isSandbox){
addBodyItem("sandbox","1")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cryptohopper.android.sdk.SharedModels.ConfigModels.HopperAPIHttpMethod

class HopperAPIIAPPurchaseRequest: HopperAPIRequest<HopperAPIPurchaseResponse> {

constructor(planId: String?,marketplaceId : String?,hopperId : String?,transactionId:String) {
constructor(planId: String?,marketplaceId : String?,hopperId : String?,transactionId:String, isSandbox: Boolean = false) {
this.httpMethod = HopperAPIHttpMethod.POST
this.needsAuthentication = true
this.changeUrlPath("/app/mobile/iap")
Expand All @@ -25,6 +25,10 @@ class HopperAPIIAPPurchaseRequest: HopperAPIRequest<HopperAPIPurchaseResponse> {
addBodyItem( "hopper_id", hopperId)
}

if(isSandbox){
addBodyItem("hopper_id","1")
}

addBodyItem( "transaction_id", transactionId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,39 @@ import cryptohopper.android.sdk.SharedModels.ConfigModels.HopperAPIHttpMethod

class HopperAPIUpdateUserProfileRequest: HopperAPIRequest<HopperCommonMessageResponse> {

constructor(name : String, addressOne : String,addressTwo : String, city : String,region : String,country : String , postalCode : String,phone : String ,website : String) {
constructor(name : String?, addressOne : String?,addressTwo : String?, city : String?,region : String?,country : String? , postalCode : String?,phone : String? ,website : String?) {
this.httpMethod = HopperAPIHttpMethod.PATCH
this.needsAuthentication = true
this.changeUrlPath("/user")
addBodyItem( "name", name)
addBodyItem( "address1", addressOne)
addBodyItem( "address2", addressTwo)
addBodyItem( "city", city)
addBodyItem( "region", region)
addBodyItem( "country", country)
addBodyItem( "postalCode", postalCode)
addBodyItem( "phone", phone)
addBodyItem( "website", website)

if(name != null && name != ""){
addBodyItem( "name", name)
}
if(addressOne != null && addressOne != ""){
addBodyItem( "address1", addressOne)
}
if(addressTwo != null && addressTwo != ""){
addBodyItem( "address2", addressTwo)
}
if(city != null && city != ""){
addBodyItem( "city", city)
}
if(region != null && region != ""){
addBodyItem( "region", region)
}
if(country != null && country != ""){
addBodyItem( "country", country)
}
if(postalCode != null && postalCode != ""){
addBodyItem( "postalCode", postalCode)
}
if(phone != null && phone != ""){
addBodyItem( "phone", phone)
}
if(website != null && website != ""){
addBodyItem( "website", website)
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ class HopperAPIV2OnboardingCreateRequest : HopperAPIRequest<HopperCommonMessageR
hopperId: Int,
isBuyingEnabled: Boolean,
isSellingEnabled: Boolean,
isEnabled: Boolean,
isHopperEnabled: Boolean,
isPortfolioSyncEnabled: Boolean,
isPaperTrading: Boolean,
quoteCurrency: String,
signallerId: Int?,
riskLevel: String?
) {
this.httpMethod = HopperAPIHttpMethod.POST
this.needsAuthentication = true
this.changeUrlPath(path = "/onboarding/edit", isV2Endpoint = true)
this.changeUrlPath(path = "/onboarding/create", isV2Endpoint = true)

val exchangeObject = HashMap<String, Any>()
exchangeObject["paperTrading"] = isPaperTrading
Expand All @@ -30,7 +31,8 @@ class HopperAPIV2OnboardingCreateRequest : HopperAPIRequest<HopperCommonMessageR
settingsObject["id"] = hopperId
settingsObject["buying"] = isBuyingEnabled
settingsObject["selling"] = isSellingEnabled
settingsObject["enabled"] = isEnabled
settingsObject["enabled"] = isHopperEnabled
settingsObject["autosync"] = isPortfolioSyncEnabled

val botObject = HashMap<String, Any>()
botObject["settings"] = settingsObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,8 @@ class CryptohopperHopper {
apiPassphrase : String? ,
extraApiKey : String? ,
extraApiSecret : String?,
autoSync : Boolean = true,
isSandbox : Boolean = false,
callback: (String?, HopperAPIError?) -> Unit
) {
HopperAPICopyBotCreateHopperRequest(
Expand All @@ -1820,7 +1822,9 @@ class CryptohopperHopper {
apiSecret = apiSecret,
apiPassphrase = apiPassphrase,
extraApiKey = extraApiKey,
extraApiSecret = extraApiSecret
extraApiSecret = extraApiSecret,
autoSync = autoSync,
isSandbox = isSandbox
).request<HopperAPIPurchaseResponse>({ data ->
callback(data.message, null)
}, { error ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class CryptohopperPurchase {
})
}

fun purchaseIAP(planId: String?,marketplaceId: String?,hopperId: String?,transactionId: String, callback : (HopperAPIPurchaseResponse?, HopperAPIError?) -> Unit) {
HopperAPIIAPPurchaseRequest(planId,marketplaceId,hopperId,transactionId).request<HopperAPIPurchaseResponse>({ data ->
fun purchaseIAP(planId: String?,marketplaceId: String?,hopperId: String?,transactionId: String,isSandBox : Boolean = false, callback : (HopperAPIPurchaseResponse?, HopperAPIError?) -> Unit) {
HopperAPIIAPPurchaseRequest(planId,marketplaceId,hopperId,transactionId,isSandBox).request<HopperAPIPurchaseResponse>({ data ->
callback(data,null)
} , { error ->
callback(null,error)
Expand Down
18 changes: 9 additions & 9 deletions sdk/src/main/java/cryptohopper/android/sdk/CryptohopperUser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ class CryptohopperUser {
///- Parameter phone: (required) phone
///- Parameter website: (required) website
fun updateUserProfile(
name: String,
addressOne: String,
addressTwo: String,
city: String,
region: String,
country: String,
postalCode: String,
phone: String,
website: String,
name: String?,
addressOne: String?,
addressTwo: String?,
city: String?,
region: String?,
country: String?,
postalCode: String?,
phone: String?,
website: String?,
callback: (String?, HopperAPIError?) -> Unit
) {
HopperAPIUpdateUserProfileRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class CryptohopperV2Onboarding {
hopperId: Int,
isBuyingEnabled: Boolean,
isSellingEnabled: Boolean,
isEnabled: Boolean,
isHopperEnabled: Boolean,
isPortfolioSyncEnabled : Boolean,
isPaperTrading: Boolean,
quoteCurrency: String,
signallerId: Int?,
Expand All @@ -74,7 +75,8 @@ class CryptohopperV2Onboarding {
hopperId,
isBuyingEnabled,
isSellingEnabled,
isEnabled,
isHopperEnabled,
isPortfolioSyncEnabled,
isPaperTrading,
quoteCurrency,
signallerId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ data class MarketCopyBot(
@SerializedName("id") val id: String?,
@SerializedName("item_id") val itemId: String?,
@SerializedName("exchange") val exchange: String?,
@SerializedName("description") val description : String?,
@SerializedName("quote_currency") val quoteCurrency: String?,
@SerializedName("allowed_coins") val allowedCoins: List<String>?,
@SerializedName("free_trial") val freeTrial: String?,
Expand Down

0 comments on commit bcb1390

Please sign in to comment.