lib/dashx/client.rb in dashx-0.2.0 vs lib/dashx/client.rb in dashx-0.3.0
- old
+ new
@@ -24,10 +24,19 @@
id
}
}
'
+ SAVE_CONTACTS_REQUEST = 'mutation SaveContacts($input: SaveContactsInput!) {
+ saveContacts(input: $input) {
+ contacts {
+ id
+ }
+ }
+ }
+ '
+
def initialize(config)
@config = config
self.class.base_uri(config.base_uri)
@@ -101,9 +110,14 @@
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
private
def make_graphql_request(request, params)