call_action 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6569517a579e1f86fcfe2c26100dd2263454075
4
+ data.tar.gz: f8ba59ec7888e397f62687b4f8be82ccc7d87497
5
+ SHA512:
6
+ metadata.gz: 27cfc7d1a77c11531ae1b2251a858975f40aa644187547db34fd2bc10d9ce6ca1a67ccfd369d05e26e70ff8857dd36220bc087db9b2c2e0506a7bd38664f9572
7
+ data.tar.gz: ba164c13b1893529ca6ca3a265f9ebe74efa33a764e4b2398f3bb6a2aef3314ae6bdd6babcac9a2b52dfa372af92d0d83d84aef0dece29d14934764dcfc2deb7
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+
2
+ *.iml
3
+ *.ipr
4
+ *.iws
5
+ *.log
6
+ *.swp
7
+ .bundle
8
+ .rakeTasks
9
+ .ruby-gemset
10
+ .ruby-version
11
+ .rvmrc
12
+ .yardoc
13
+ coverage/
14
+ doc/
15
+ Gemfile.lock
16
+ gemfiles/*.lock
17
+ pkg
18
+ tmp/*
data/README.md ADDED
@@ -0,0 +1 @@
1
+ CallAction
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,90 @@
1
+ require "net/http"
2
+ require 'contact'
3
+ require "json"
4
+ require "uri"
5
+
6
+ class CallAction
7
+
8
+ attr_accessor :token, :base_url, :api_version, :headers
9
+ attr_writer :configuration
10
+
11
+ def self.configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def self.reset
16
+ @configuration = Configuration.new
17
+ end
18
+
19
+ def self.configure
20
+ yield(configuration)
21
+ end
22
+
23
+ # Initializer
24
+ def initialize headers = {}
25
+ @token = CallAction.configuration.auth_token
26
+ @api_version = CallAction.configuration.api_version
27
+ @base_url = "https://callaction.co/api/"
28
+ @headers = {"Accept" => "application/json", "Content-Type" => "application/json", "X-AUTH-TOKEN" => @token}.merge(headers)
29
+ end
30
+
31
+ # To test installation
32
+ def self.hi
33
+ puts "Hello world!"
34
+ end
35
+
36
+ # To get list of all contacts
37
+ def contacts
38
+ url = URI.parse("#{@base_url}#{@api_version}/contacts")
39
+ request = Net::HTTP::Get.new(url.request_uri)
40
+
41
+ @headers.each {|k, v| request[k] = v }
42
+
43
+ response = Net::HTTP.start(url.hostname, url.port, :use_ssl => url.scheme == 'https') do |http|
44
+ http.request(request)
45
+ end
46
+
47
+ JSON.parse(response.body)["contacts"].collect {|contact| Contact.new contact }
48
+ end
49
+
50
+ def activities contact_id
51
+ url = URI.parse("#{@base_url}#{@api_version}/contacts/#{contact_id}/activity")
52
+ request = Net::HTTP::Get.new(url.request_uri)
53
+
54
+ @headers.each {|k, v| request[k] = v }
55
+
56
+ response = Net::HTTP.start(url.hostname, url.port, :use_ssl => url.scheme == 'https') do |http|
57
+ http.request(request)
58
+ end
59
+
60
+ JSON.parse(response.body)["activities"]
61
+ end
62
+
63
+ def channels
64
+ url = URI.parse("#{@base_url}#{@api_version}/channels")
65
+ request = Net::HTTP::Get.new(url.request_uri)
66
+
67
+ @headers.each {|k, v| request[k] = v }
68
+
69
+ response = Net::HTTP.start(url.hostname, url.port, :use_ssl => url.scheme == 'https') do |http|
70
+ http.request(request)
71
+ end
72
+
73
+ JSON.parse(response.body)["channels"]
74
+ end
75
+
76
+ def sources
77
+ url = URI.parse("#{@base_url}#{@api_version}/sources")
78
+ request = Net::HTTP::Get.new(url.request_uri)
79
+
80
+ @headers.each {|k, v| request[k] = v }
81
+
82
+ response = Net::HTTP.start(url.hostname, url.port, :use_ssl => url.scheme == 'https') do |http|
83
+ http.request(request)
84
+ end
85
+
86
+ JSON.parse(response.body)["sources"]
87
+ end
88
+
89
+
90
+ end
@@ -0,0 +1,8 @@
1
+ class Configuration
2
+ attr_accessor :auth_token, :api_version
3
+
4
+ def initialize
5
+ @auth_token = nil
6
+ @api_version = nil
7
+ end
8
+ end
data/lib/contact.rb ADDED
@@ -0,0 +1,17 @@
1
+ class Contact
2
+
3
+ def initialize(hash)
4
+ hash.each do |k,v|
5
+ self.instance_variable_set("@#{k}", v.is_a?(Hash) ? Hashit.new(v) : v)
6
+ self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")})
7
+ self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)})
8
+ end
9
+ end
10
+
11
+
12
+ def activities
13
+ call_action = CallAction.new
14
+ call_action.activities self.id
15
+ end
16
+
17
+ end
@@ -0,0 +1,11 @@
1
+ module CallAction
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::NamedBase
4
+ source_root File.expand_path("../templates", __FILE__)
5
+
6
+ def copy_initializer_file
7
+ copy_file "initializer.rb", "config/initializers/call_action.rb"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ CallAction.configure do |config|
2
+ config.api_version = 'v1'
3
+ config.auth_token = 'YOUR-CALL-ACTION-TOKEN'
4
+ end
@@ -0,0 +1,11 @@
1
+ module CallAction
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../templates", __FILE__)
5
+
6
+ def copy_initializer_file
7
+ copy_file "initializer.rb", "config/initializers/call_action.rb"
8
+ end
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: call_action
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Shahzad Tariq
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
33
+ description: Ruby wrapper for CallAction API to be used within Ruby On Rails (RoR)
34
+ and other Ruby based frameworks
35
+ email: m.shahzad.tariq@hotmaul.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - .gitignore
41
+ - README.md
42
+ - call_action-1.2.0.gem
43
+ - call_action-1.2.1.gem
44
+ - call_action-1.2.2.gem
45
+ - call_action-1.2.3.gem
46
+ - call_action-1.2.4.gem
47
+ - call_action-1.2.5.gem
48
+ - call_action-1.2.6.gem
49
+ - call_action-1.2.7.gem
50
+ - call_action-1.2.8.gem
51
+ - lib/call_action.rb
52
+ - lib/configuration.rb
53
+ - lib/contact.rb
54
+ - lib/generators/install_generator.rb
55
+ - lib/generators/templates/initializer.rb
56
+ - lib/install_generator.rb
57
+ homepage: https://callaction.co/documentation/developers/api/v1/index.html
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.4.7
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: CallAction API
81
+ test_files: []
82
+ has_rdoc: