Skip to content

Commit e306fc8

Browse files
authored
Feature: Clone vAtom (BLOCKvIO#135)
1 parent 2071459 commit e306fc8

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ repositories {
6767

6868
def libraryGroupId = 'io.blockv.sdk'
6969
def libraryArtifactId = 'core'
70-
def libraryVersion = '3.0.1'
70+
def libraryVersion = '3.1.0'
7171

7272
task sourceJar(type: Jar) {
7373
from android.sourceSets.main.java.srcDirs

core/src/main/java/io/blockv/core/client/manager/VatomManager.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ interface VatomManager {
156156
token: String
157157
): Completable
158158

159+
/**
160+
* Attempts to clone a vAtom to a user.
161+
*
162+
* @param id is the vAtom's id.
163+
* @param tokenType is the type of the user's token.
164+
* @param token is the user's token matching the provided type.
165+
* @return new Completable instance.
166+
*/
167+
fun cloneVatom(
168+
id: String,
169+
tokenType: TokenType,
170+
token: String
171+
): Completable
172+
159173
/**
160174
* Attempts to drop a vAtom on the map.
161175
*
@@ -225,6 +239,9 @@ interface VatomManager {
225239
TRANSFER {
226240
override fun action(): String = "Transfer"
227241
},
242+
CLONE {
243+
override fun action(): String = "Clone"
244+
},
228245
DROP {
229246
override fun action(): String = "Drop"
230247
},

core/src/main/java/io/blockv/core/client/manager/VatomManagerImpl.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ package io.blockv.core.client.manager
1212

1313
import io.blockv.common.builder.DiscoverQueryBuilder
1414
import io.blockv.common.internal.net.rest.api.VatomApi
15-
import io.blockv.common.internal.net.rest.request.*
16-
import io.blockv.common.model.*
15+
import io.blockv.common.internal.net.rest.request.GeoGroupRequest
16+
import io.blockv.common.internal.net.rest.request.GeoRequest
17+
import io.blockv.common.internal.net.rest.request.InventoryRequest
18+
import io.blockv.common.internal.net.rest.request.PerformActionRequest
19+
import io.blockv.common.internal.net.rest.request.TrashVatomRequest
20+
import io.blockv.common.internal.net.rest.request.VatomRequest
21+
import io.blockv.common.model.GeoGroup
22+
import io.blockv.common.model.StateUpdateEvent
23+
import io.blockv.common.model.Vatom
24+
import io.blockv.common.model.VatomProperty
25+
import io.blockv.common.model.VatomVisibility
1726
import io.blockv.common.util.JsonUtil
1827
import io.reactivex.Completable
1928
import io.reactivex.Single
@@ -124,6 +133,17 @@ class VatomManagerImpl(val api: VatomApi) : VatomManager {
124133
return Completable.fromSingle(preformAction(VatomManager.Action.TRANSFER, payload))
125134
}
126135

136+
override fun cloneVatom(id: String, tokenType: VatomManager.TokenType, token: String): Completable {
137+
val payload = JSONObject()
138+
payload.put("this.id", id)
139+
when (tokenType) {
140+
VatomManager.TokenType.EMAIL -> payload.put("new.owner.email", token)
141+
VatomManager.TokenType.PHONE_NUMBER -> payload.put("new.owner.phone_number", token)
142+
VatomManager.TokenType.ID -> payload.put("new.owner.email", token)
143+
}
144+
return Completable.fromSingle(preformAction(VatomManager.Action.CLONE, payload))
145+
}
146+
127147
override fun dropVatom(id: String, latitude: Double, longitude: Double): Completable {
128148
val payload = JSONObject()
129149
payload.put("this.id", id)

0 commit comments

Comments
 (0)