-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #839 from helium/macpie/verification_mapping
Verification Mapping
- Loading branch information
Showing
26 changed files
with
1,289 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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,58 @@ | ||
use crate::{ | ||
traits::{MsgDecode, MsgTimestamp, TimestampDecode, TimestampEncode}, | ||
Error, Result, | ||
}; | ||
use chrono::{DateTime, Utc}; | ||
use helium_crypto::PublicKeyBinary; | ||
use helium_proto::services::poc_mobile::SubscriberVerifiedMappingEventReqV1; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)] | ||
pub struct SubscriberVerifiedMappingEvent { | ||
pub subscriber_id: Vec<u8>, | ||
pub total_reward_points: u64, | ||
pub timestamp: DateTime<Utc>, | ||
pub carrier_mapping_key: PublicKeyBinary, | ||
} | ||
|
||
impl MsgDecode for SubscriberVerifiedMappingEvent { | ||
type Msg = SubscriberVerifiedMappingEventReqV1; | ||
} | ||
|
||
impl MsgTimestamp<Result<DateTime<Utc>>> for SubscriberVerifiedMappingEventReqV1 { | ||
fn timestamp(&self) -> Result<DateTime<Utc>> { | ||
self.timestamp.to_timestamp() | ||
} | ||
} | ||
|
||
impl MsgTimestamp<u64> for SubscriberVerifiedMappingEvent { | ||
fn timestamp(&self) -> u64 { | ||
self.timestamp.encode_timestamp() | ||
} | ||
} | ||
|
||
impl From<SubscriberVerifiedMappingEvent> for SubscriberVerifiedMappingEventReqV1 { | ||
fn from(v: SubscriberVerifiedMappingEvent) -> Self { | ||
let timestamp = v.timestamp(); | ||
SubscriberVerifiedMappingEventReqV1 { | ||
subscriber_id: v.subscriber_id, | ||
total_reward_points: v.total_reward_points, | ||
timestamp, | ||
carrier_mapping_key: v.carrier_mapping_key.into(), | ||
signature: vec![], | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<SubscriberVerifiedMappingEventReqV1> for SubscriberVerifiedMappingEvent { | ||
type Error = Error; | ||
fn try_from(v: SubscriberVerifiedMappingEventReqV1) -> Result<Self> { | ||
let timestamp = v.timestamp()?; | ||
Ok(Self { | ||
subscriber_id: v.subscriber_id, | ||
total_reward_points: v.total_reward_points, | ||
timestamp, | ||
carrier_mapping_key: v.carrier_mapping_key.into(), | ||
}) | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
file_store/src/subscriber_verified_mapping_event_ingest_report.rs
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 crate::{ | ||
subscriber_verified_mapping_event::SubscriberVerifiedMappingEvent, | ||
traits::{MsgDecode, MsgTimestamp, TimestampDecode, TimestampEncode}, | ||
Error, Result, | ||
}; | ||
use chrono::{DateTime, Utc}; | ||
use helium_proto::services::poc_mobile::{ | ||
SubscriberVerifiedMappingEventIngestReportV1, SubscriberVerifiedMappingEventReqV1, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)] | ||
pub struct SubscriberVerifiedMappingEventIngestReport { | ||
pub received_timestamp: DateTime<Utc>, | ||
pub report: SubscriberVerifiedMappingEvent, | ||
} | ||
|
||
impl MsgDecode for SubscriberVerifiedMappingEventIngestReport { | ||
type Msg = SubscriberVerifiedMappingEventIngestReportV1; | ||
} | ||
|
||
impl MsgTimestamp<Result<DateTime<Utc>>> for SubscriberVerifiedMappingEventIngestReportV1 { | ||
fn timestamp(&self) -> Result<DateTime<Utc>> { | ||
self.received_timestamp.to_timestamp() | ||
} | ||
} | ||
|
||
impl MsgTimestamp<u64> for SubscriberVerifiedMappingEventIngestReport { | ||
fn timestamp(&self) -> u64 { | ||
self.received_timestamp.encode_timestamp() | ||
} | ||
} | ||
|
||
impl From<SubscriberVerifiedMappingEventIngestReport> | ||
for SubscriberVerifiedMappingEventIngestReportV1 | ||
{ | ||
fn from(v: SubscriberVerifiedMappingEventIngestReport) -> Self { | ||
let received_timestamp = v.timestamp(); | ||
let report: SubscriberVerifiedMappingEventReqV1 = v.report.into(); | ||
Self { | ||
received_timestamp, | ||
report: Some(report), | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<SubscriberVerifiedMappingEventIngestReportV1> | ||
for SubscriberVerifiedMappingEventIngestReport | ||
{ | ||
type Error = Error; | ||
fn try_from(v: SubscriberVerifiedMappingEventIngestReportV1) -> Result<Self> { | ||
Ok(Self { | ||
received_timestamp: v.timestamp()?, | ||
report: v | ||
.report | ||
.ok_or_else(|| { | ||
Error::not_found("ingest SubscriberVerifiedMappingEventIngestReport report") | ||
})? | ||
.try_into()?, | ||
}) | ||
} | ||
} |
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.