-
Notifications
You must be signed in to change notification settings - Fork 23
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
4 changed files
with
101 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use tonic::{async_trait, Request}; | ||
use xmtp_proto::{ | ||
api_client::{Error, ErrorKind, XmtpIdentityClient}, | ||
xmtp::identity::api::v1::{ | ||
GetIdentityUpdatesRequest as GetIdentityUpdatesV2Request, | ||
GetIdentityUpdatesResponse as GetIdentityUpdatesV2Response, GetInboxIdsRequest, | ||
GetInboxIdsResponse, PublishIdentityUpdateRequest, PublishIdentityUpdateResponse, | ||
}, | ||
}; | ||
|
||
use crate::Client; | ||
|
||
#[async_trait] | ||
impl XmtpIdentityClient for Client { | ||
async fn publish_identity_update( | ||
&self, | ||
request: PublishIdentityUpdateRequest, | ||
) -> Result<PublishIdentityUpdateResponse, Error> { | ||
let mut tonic_request = Request::new(request); | ||
tonic_request | ||
.metadata_mut() | ||
.insert("x-app-version", self.app_version.clone()); | ||
let client = &mut self.identity_client.clone(); | ||
|
||
let res = client.publish_identity_update(tonic_request).await; | ||
|
||
res.map(|response| response.into_inner()) | ||
.map_err(|err| Error::new(ErrorKind::IdentityError).with(err)) | ||
} | ||
|
||
async fn get_inbox_ids( | ||
&self, | ||
request: GetInboxIdsRequest, | ||
) -> Result<GetInboxIdsResponse, Error> { | ||
let mut tonic_request = Request::new(request); | ||
tonic_request | ||
.metadata_mut() | ||
.insert("x-app-version", self.app_version.clone()); | ||
let client = &mut self.identity_client.clone(); | ||
|
||
let res = client.get_inbox_ids(tonic_request).await; | ||
|
||
res.map(|response| response.into_inner()) | ||
.map_err(|err| Error::new(ErrorKind::IdentityError).with(err)) | ||
} | ||
|
||
async fn get_identity_updates_v2( | ||
&self, | ||
request: GetIdentityUpdatesV2Request, | ||
) -> Result<GetIdentityUpdatesV2Response, Error> { | ||
let mut tonic_request = Request::new(request); | ||
tonic_request | ||
.metadata_mut() | ||
.insert("x-app-version", self.app_version.clone()); | ||
let client = &mut self.identity_client.clone(); | ||
|
||
let res = client.get_identity_updates(tonic_request).await; | ||
|
||
res.map(|response| response.into_inner()) | ||
.map_err(|err| Error::new(ErrorKind::IdentityError).with(err)) | ||
} | ||
} |
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