Class: Appurify::Client
- Inherits:
-
Object
- Object
- Appurify::Client
- Defined in:
- lib/appurify/client.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#key ⇒ Object
Returns the value of attribute key.
-
#last_request ⇒ Object
Returns the value of attribute last_request.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#port ⇒ Object
Returns the value of attribute port.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
- #access_token ⇒ Object
- #apps ⇒ Object
- #device_types ⇒ Object
-
#initialize(key, secret, options = {}) ⇒ Client
constructor
A new instance of Client.
- #monitor_test(test_run_id) ⇒ Object
- #network_conditions ⇒ Object
- #run_test(device_type_id, app_id, test_id, async = 1) ⇒ Object
- #tests ⇒ Object
- #upload_app(source_type, source) ⇒ Object
- #upload_app_from_file(app_path) ⇒ Object
- #upload_app_from_url(app_url) ⇒ Object
- #upload_config(test_id, config_src) ⇒ Object
- #upload_device_conditions(test_id, conditions) ⇒ Object
- #upload_test(source_type, source, test_type) ⇒ Object
- #upload_test_from_file(test_path, test_type) ⇒ Object
- #upload_test_from_url(test_url, test_type) ⇒ Object
Constructor Details
#initialize(key, secret, options = {}) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/appurify/client.rb', line 5 def initialize(key, secret, ={}) @key = key @secret = secret @scheme, @host, @port, @request_timeout, @open_timeout = { scheme: "https", host: HOSTNAME, port: 443, request_timeout: 600, open_timeout: 10 }.merge().values end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/appurify/client.rb', line 3 def host @host end |
#key ⇒ Object
Returns the value of attribute key.
3 4 5 |
# File 'lib/appurify/client.rb', line 3 def key @key end |
#last_request ⇒ Object
Returns the value of attribute last_request.
3 4 5 |
# File 'lib/appurify/client.rb', line 3 def last_request @last_request end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
3 4 5 |
# File 'lib/appurify/client.rb', line 3 def open_timeout @open_timeout end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/appurify/client.rb', line 3 def port @port end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
3 4 5 |
# File 'lib/appurify/client.rb', line 3 def request_timeout @request_timeout end |
#scheme ⇒ Object
Returns the value of attribute scheme.
3 4 5 |
# File 'lib/appurify/client.rb', line 3 def scheme @scheme end |
#secret ⇒ Object
Returns the value of attribute secret.
3 4 5 |
# File 'lib/appurify/client.rb', line 3 def secret @secret end |
Instance Method Details
#access_token ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/appurify/client.rb', line 18 def access_token unless access_token_active? url = build_url("access_token", "generate") data = { :key => @key, :secret => @secret } #result = post(url, data, false) result = post(url, data) @access_token = result["access_token"] @access_token_ttl = result["ttl"] @access_token_created = Time.now end @access_token end |
#apps ⇒ Object
46 47 48 49 |
# File 'lib/appurify/client.rb', line 46 def apps url = build_url("apps", "list") get(url) end |
#device_types ⇒ Object
36 37 38 39 |
# File 'lib/appurify/client.rb', line 36 def device_types url = build_url("devices", "list") get(url) end |
#monitor_test(test_run_id) ⇒ Object
141 142 143 144 145 |
# File 'lib/appurify/client.rb', line 141 def monitor_test(test_run_id) url = build_url("tests", "check") params = { test_run_id: test_run_id } get(url, params) end |
#network_conditions ⇒ Object
41 42 43 44 |
# File 'lib/appurify/client.rb', line 41 def network_conditions url = build_url("devices", "config/networks/list") get(url) end |
#run_test(device_type_id, app_id, test_id, async = 1) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/appurify/client.rb', line 128 def run_test(device_type_id, app_id, test_id, async=1) url = build_url("tests", "run") data = { :access_token => access_token, :device_type_id => device_type_id, :app_id => app_id, :test_id => test_id, :async => async } post(url, data) end |
#tests ⇒ Object
51 52 53 54 |
# File 'lib/appurify/client.rb', line 51 def tests url = build_url("tests", "list") get(url) end |
#upload_app(source_type, source) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/appurify/client.rb', line 65 def upload_app(source_type, source) url = build_url("apps", "upload") data = { :access_token => access_token, :source_type => source_type, :source => source } post(url, data) end |
#upload_app_from_file(app_path) ⇒ Object
56 57 58 59 |
# File 'lib/appurify/client.rb', line 56 def upload_app_from_file(app_path) abort "App not found" unless File.exists? app_path upload_app("raw", File.new(app_path, 'rb')) end |
#upload_app_from_url(app_url) ⇒ Object
61 62 63 |
# File 'lib/appurify/client.rb', line 61 def upload_app_from_url(app_url) upload_app("url", app_url) end |
#upload_config(test_id, config_src) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/appurify/client.rb', line 97 def upload_config(test_id, config_src) abort "Config not found" unless File.exists? config_src url = build_url("config", "upload") data = { :access_token => access_token, :test_id => test_id, :source => File.new(config_src, 'rb') } post(url, data) end |
#upload_device_conditions(test_id, conditions) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/appurify/client.rb', line 109 def upload_device_conditions(test_id, conditions) url = build_url("config", "upload") file_data = "[appurify]\n" + conditions.keys.collect{ |k| k.to_s + "=" + conditions[k].to_s }.join("\n") file = StringIO.new(file_data) file.class.class_eval { attr_accessor :name } file.class.class_eval { attr_accessor :path } file.name = "config.cnf" file.path = "config.cnf" data = { :access_token => access_token, :test_id => test_id, :source => file } post(url, data) end |
#upload_test(source_type, source, test_type) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/appurify/client.rb', line 85 def upload_test(source_type, source, test_type) url = build_url("tests", "upload") data = { :access_token => access_token, :source_type => source_type, :test_type => test_type, :source => source } post(url, data) end |
#upload_test_from_file(test_path, test_type) ⇒ Object
76 77 78 79 |
# File 'lib/appurify/client.rb', line 76 def upload_test_from_file(test_path, test_type) abort "Tests not found" unless File.exists? test_path upload_test("raw", File.new(test_path, 'rb'), test_type) end |
#upload_test_from_url(test_url, test_type) ⇒ Object
81 82 83 |
# File 'lib/appurify/client.rb', line 81 def upload_test_from_url(test_url, test_type) upload_test("url", test_url, test_type) end |