lib/dashx/client.rb in dashx-0.4.0 vs lib/dashx/client.rb in dashx-0.5.0
- old
+ new
@@ -33,10 +33,37 @@
}
}
}
'
+ FETCH_ITEM_REQUEST = 'query FetchItem($input: FetchItemInput) {
+ fetchItem(input: $input) {
+ id
+ installationId
+ name
+ identifier
+ description
+ createdAt
+ updatedAt
+ pricings {
+ id
+ kind
+ amount
+ originalAmount
+ isRecurring
+ recurringInterval
+ recurringIntervalUnit
+ appleProductIdentifier
+ googleProductIdentifier
+ currencyCode
+ createdAt
+ updatedAt
+ }
+ }
+ }
+ '
+
def initialize(config)
@config = config
self.class.base_uri(config.base_uri)
@@ -93,31 +120,19 @@
end
def track(event, uid, data = nil)
symbolize_keys! data unless data.nil?
- make_graphql_request(TRACK_EVENT_REQUEST, { event: event, uid: uid, data: data })
+ make_graphql_request(TRACK_EVENT_REQUEST, { event: event, accountUid: uid, data: data })
end
- def generate_identity_token(uid, options = {})
- check_presence!(uid, 'uid')
- symbolize_keys! options
-
- kind = options[:kind] || 'regular'
- plain_text = "v1;#{kind};#{uid}"
-
- cipher = OpenSSL::Cipher::AES.new(256, :GCM).encrypt
- cipher.key = @config.private_key
- nonce = cipher.random_iv
- cipher.iv = nonce
- encrypted = cipher.update(plain_text) + cipher.final
- encrypted_token = "#{nonce}#{encrypted}#{cipher.auth_tag}"
- Base64.urlsafe_encode64(encrypted_token)
- end
-
def save_contacts(uid, contacts = [])
contacts.each(&:symbolize_keys!)
make_graphql_request(SAVE_CONTACTS_REQUEST, { uid: uid, contacts: contacts })
+ end
+
+ def fetch_item(identifier)
+ make_graphql_request(FETCH_ITEM_REQUEST, { identifier: identifier })
end
private
def make_graphql_request(request, params)