dito 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5a229f01c878d52255252b81dfe96b31ed516fa
4
- data.tar.gz: af62fe80335ef38ef5312073e6b5622eeadf095b
3
+ metadata.gz: 97c83e1dbb3ebe85636f9b66dacaf0b7301873b5
4
+ data.tar.gz: 6214c8f64ca8c5b2ef5d66e4d4536d94c5345257
5
5
  SHA512:
6
- metadata.gz: 9fd4ae687d2d81c2c83cb138bd8ac82a7ced44b162b9036f7ebd00a835105dfca14db8bd8dc98653e13a7768234f33fa330c789df4ef95c7b5eca388514472d4
7
- data.tar.gz: a9bb15ec4b544e2ce209d06ede900ea4031e9c98dd623f9e099acc0cbc41a58179d0d299385fda3bc9df05ac1bdfee919ecb256c3732667c97efcdd44e993749
6
+ metadata.gz: b47bedc77e162f8811ac2940d9776507c38e6b951903dee42fee3ef1475d9a1296f2ef5a48cd8a6ce2d1a78c36f86dfdd62ae556dc95ce600dfe339ce28c4197
7
+ data.tar.gz: 0af86f05bfc195338d7b8f676bb43cb4959e464b10f6bae2746d381509b07bf02c4a0965a546331aa0f2d81606715500eb79e3fe2688f2486527eea36a08c18e
@@ -1,12 +1,14 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  require "helpers/symbolize_keys"
4
+ require "helpers/generate_credentials"
4
5
 
5
6
  require "dito/version"
6
7
  require "dito/configuration"
7
8
  require "dito/domains"
8
9
  require "dito/request"
9
10
  require "dito/identify"
11
+ require "dito/alias"
10
12
  require "dito/track"
11
13
 
12
14
  module Dito
@@ -0,0 +1,35 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module Dito
4
+ def self.alias(options = {})
5
+ Dito.symbolize_keys!(options)
6
+
7
+ settings = Dito.generate_alias_settings(options)
8
+
9
+ return { :error => settings[:error] } if settings[:error].present?
10
+
11
+ Dito::Request.post 'login', "/users/#{settings[:id]}/link", settings[:params]
12
+ end
13
+
14
+ def self.unalias(options = {})
15
+ Dito.symbolize_keys!(options)
16
+
17
+ settings = Dito.generate_alias_settings(options)
18
+
19
+ return { :error => settings[:error] } if settings[:error].present?
20
+
21
+ Dito::Request.post 'login', "/users/#{settings[:id]}/unlink", settings[:params]
22
+ end
23
+
24
+ def self.generate_alias_settings(options = {})
25
+ id, id_type = Dito.generate_credentials(options)
26
+
27
+ return { :error => { :message => 'Missing the user id param. See the available options here: http://developers.dito.com.br/docs/sdks/ruby' } } if id.blank?
28
+ return { :error => { :message => 'Missing the accounts param. See the available options here: http://developers.dito.com.br/docs/rest-api/users' } } if options[:accounts].blank?
29
+
30
+ params = { :accounts => options[:accounts] }
31
+ params[:id_type] = id_type if id_type.present?
32
+
33
+ { :id => id, :params => params }
34
+ end
35
+ end
@@ -4,24 +4,9 @@ module Dito
4
4
  def self.track options = {}
5
5
  Dito.symbolize_keys!(options)
6
6
 
7
- if options[:reference].present?
8
- id = options[:reference]
9
- id_type = nil
10
- elsif options[:facebook_id].present?
11
- id = options[:facebook_id]
12
- id_type = 'facebook_id'
13
- elsif options[:google_plus_id].present?
14
- id = options[:google_plus_id]
15
- id_type = 'google_plus_id'
16
- elsif options[:twitter_id].present?
17
- id = options[:twitter_id]
18
- id_type = 'twitter_id'
19
- elsif options[:id].present?
20
- id = options[:id]
21
- id_type = 'id'
22
- else
23
- return { :error => { :message => 'Missing the user id param. See the available options here: http://developers.dito.com.br/docs/sdks/ruby' } }
24
- end
7
+ id, id_type = Dito.generate_credentials(options)
8
+
9
+ return { :error => { :message => 'Missing the user id param. See the available options here: http://developers.dito.com.br/docs/sdks/ruby' } } if id.blank?
25
10
 
26
11
  params = { :event => options[:event].to_json }
27
12
  params[:id_type] = id_type if id_type.present?
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module Dito
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
@@ -0,0 +1,29 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ require 'active_support/core_ext/hash'
4
+
5
+ module Dito
6
+ def self.generate_credentials(options)
7
+ if options[:reference].present?
8
+ id = options[:reference]
9
+ id_type = nil
10
+ elsif options[:facebook_id].present?
11
+ id = options[:facebook_id]
12
+ id_type = 'facebook_id'
13
+ elsif options[:google_plus_id].present?
14
+ id = options[:google_plus_id]
15
+ id_type = 'google_plus_id'
16
+ elsif options[:twitter_id].present?
17
+ id = options[:twitter_id]
18
+ id_type = 'twitter_id'
19
+ elsif options[:id].present?
20
+ id = options[:id]
21
+ id_type = 'id'
22
+ else
23
+ id = nil
24
+ id_type = nil
25
+ end
26
+
27
+ return id, id_type
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Nogueira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2015-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,12 +82,14 @@ files:
82
82
  - dito.gemspec
83
83
  - dito.pem
84
84
  - lib/dito.rb
85
+ - lib/dito/alias.rb
85
86
  - lib/dito/configuration.rb
86
87
  - lib/dito/domains.rb
87
88
  - lib/dito/identify.rb
88
89
  - lib/dito/request.rb
89
90
  - lib/dito/track.rb
90
91
  - lib/dito/version.rb
92
+ - lib/helpers/generate_credentials.rb
91
93
  - lib/helpers/symbolize_keys.rb
92
94
  homepage: http://dito.com.br/
93
95
  licenses: