harmony-service 0.3.2 → 0.3.3

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: 53aeacaffe5532320409e5e33156402823318bee
4
- data.tar.gz: 6eb9fd302ea3efc697d3b98d78261b800eaff698
3
+ metadata.gz: eb5d91a50a1757a98e3db2b33b92fee6971f437d
4
+ data.tar.gz: c2dc034579f0bf15dfc04947dc82963de75df192
5
5
  SHA512:
6
- metadata.gz: 620c6ce2e799e35cc9789f468533c3242aa8b5b7aee6a5c0e42686def01baaa516e088f98ac93f285a0bd1d12c28e49bd4d58abfae0e33ac7608f199fa82633c
7
- data.tar.gz: bb716bd3ece341550b55b585c9180f858d170d7b2fb1d38608e37b91ec657f8e23f55212596b23dd737c653a1afbe165716f036a7c7a680193ef135166526a5c
6
+ metadata.gz: 7474d97b0161d7b254388ffd89c60f3d4fd8fd7f6bac8d4856aef436463a243856af569cb68cc8d9346b74617d85300a53efa1f8b9651553bd53f10c711cde79
7
+ data.tar.gz: a9c14a9efcd452c197bfe77f542f2fd32aacb5033268d6aebf9c24f6bb0f64bcc9bce252390e87e4563c6b6d42b4335d858b5ff8a57e306548aca417b7c9101b
data/Gemfile CHANGED
@@ -1,5 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
3
8
  # Specify your gem's dependencies in harmony-service.gemspec
4
9
  gemspec
5
10
 
data/README.md CHANGED
@@ -1,21 +1,97 @@
1
1
  # Harmony::Service
2
2
 
3
- The Harmony Service gem simplifies creation of a Service in the Harmony Platform.
3
+ The Harmony Service gem simplifies creation of a micro-service (Service) in the Harmony Platform.
4
+
5
+ You can connect your Service to pages and Apps inside Harmony. Whenever a page or App connected to your service is triggered it will route a message through to your service with a representative class. You should respond with the appropriate class encapsulating any data you want to display. For example, if your Service recieves a ``Harmony::Service::Chart::Request``, it should return a ``Harmony::Service::Chart::Response``.
6
+
7
+ You can find the relevant mappings [here](https://github.com/HarmonyMobile/harmony-service/blob/master/lib/harmony/service/rpc_service.rb#L95).
4
8
 
5
9
  ## Installation
6
10
 
7
11
  1. Create a new Service via the Harmony platform
8
- 1. Download the code for your Service.
9
- 1. Run `bundle install`
12
+ 2. Download the [Harmony Service Template](https://github.com/HarmonyMobile/harmony-service-template).
13
+ 3. Add your own code. You will need to use your own source code control.
10
14
 
11
15
  ## Usage
12
16
 
13
- In order to test your code locally you can run `bundle exec rspec`. Once you have completed development you can upload into the Harmony Platform.
17
+ In order to test your code locally you can run `bundle exec rspec`. Once you have completed development you can upload into Harmony Platform.
18
+
19
+ The service has 9 request models at the moment, namely..
20
+
21
+ | Model | Purpose |
22
+ | ----------- | ---------------------------------------- |
23
+ | Action List | Provide a list of purchase order items for approval or rejection |
24
+ | Calculator | Turn a loan calculation spreadsheet into an optimised mobile app |
25
+ | Chart | Display Data and various other chart types |
26
+ | Document | Product briefs, presentations, and other documents for the app |
27
+ | Capture | Capture documents or evidence |
28
+ | Instruction | Text and Images to help use the app |
29
+ | Video | Stream viedos and content |
30
+ | Webpage | Embed a company webpage or URL |
31
+ | Form | Create forms to document and photograph health and safety incidents |
32
+
33
+ For the first integration use case, let's walk through the creation of a simple *Harmony Calculator* based service. For this we will be cloning the [Harmony Service Weather](https://github.com/HarmonyMobile/harmony-service-weather) example and integrate it with the Harmony environment. you can use the documentation present in that repository to understand how the service works.
34
+
35
+ Go to *OpenWeatherMap.org* and get a free API key, follow instructions on how to setup the service on the Harmony service plugin that incorporates this feature. From the documentation presented we examine the service
36
+
37
+ ```ruby
38
+ def work_with_request(request)
39
+ case request
40
+ when Harmony::Service::Calculator::Request
41
+ if request.inputs && request.inputs.include?('city') && request.outputs.include?('temperature')
42
+ city = request.inputs['city']
43
+ weather = weather_service.current_temperature(city)
44
+ Harmony::Service::Calculator::Response.new({outputs: {temperature: weather}})
45
+ else
46
+ Harmony::Service::Calculator::Response.new({outputs: {city: ['London','New York,US','Bangalore']}})
47
+ end
48
+ end
49
+ end
50
+
51
+ private
52
+ def weather_service
53
+ @weather_service ||= WeatherService.new(ENV['open_weather_map_api_key'])
54
+ end
55
+ ```
56
+
57
+ From the above service code we can notice that we request the service setup for two kinds of interaction, first being the standard use case of passing *City* as an input and expecting *Temperature* as an output. Most of the straight forward query integrations would do well with the *Calculator* request model
58
+
59
+ The interface gives us access to `:uri, :inputs, :outputs` that can be passed in as a ***Request***, while the ***Response*** channel gives us `:outputs`. The service invokes the *work_with_request* function, which as you can see hooks up to the weather service by passing the `city` parameter to it. if there are no inputs the service will respond with the ideal inputs. Once the service has been prepared and automated tests have been installed, let's prepare the service for apps on Harmony.
60
+
61
+ 1. Log into www.harmonyplatform.io
62
+
63
+ 2. Click on *Services*, select *+New*
64
+
65
+ 3. Choose **Custom**, Create service
66
+
67
+ 4. Under **New Custom Service**, Choose a name - let's call it *Weather Checker*
68
+
69
+ 5. Leave the permission type as-is
70
+
71
+ 6. Create an environment variable `open_weather_api_key` to be used by the service and populate it with the one obtained from the website. this populates *config/application.yml* via Figaro o be
72
+
73
+ ![service_settings](images/service_settings.png)
74
+
75
+ 7. In the repository folder, run the packaging command as indicated in the build box, to generate a compressed image in the *builds* folder. select *Choose file* and pick the said file.
76
+
77
+ ![build_settings](images/build_settings.png)
78
+
79
+ 8. Click on *Create build*, which triggers an upload. wait for the status to say Build succeeded. this should take a few minutes.
80
+
81
+ 9. Click on ***Apps***, on the main navigation bar, and selected *+New*, Enter a name
82
+
83
+ 10. Select *Add a Page*, and choose *Calculator*
84
+
85
+ 11. In Inputs type *City* and in Outputs type *Temperature*, this must correspond to what the service recieves as per the code above. select the service that we just setup, the names don't have to match.
86
+
87
+ ![calc_page_setup](images/calc_page_setup.png)
88
+
89
+ 12. Choose ***Save & Test***, You shold be able to get a result from the service here
14
90
 
15
- ## Development
91
+ 13. Now enter *Harmony App* and test out the same and see if the output matches
16
92
 
17
- Your Service should respond to request messages appropriately. You can find the relevant mappings [here](https://github.com/HarmonyMobile/harmony-service/blob/master/lib/harmony/service/rpc_service.rb#L95).
93
+ Once you get it working, this can serve as a template to modify and integrate your own services, and extend this to include multiple inputs, mutiple services and several pages to suit your business needs.
18
94
 
19
95
  ## License
20
96
 
21
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
97
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
Binary file
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  class Harmony::Service::ActionList::Item < Harmony::Service::Response
2
- attr_accessor :id, :title, :subtitle, :actions, :detail_url, :detail_html
2
+ attr_accessor :id, :title, :subtitle, :actions, :detail_html
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Harmony::Service::Flow::EndedRequest < Harmony::Service::Request
2
- attr_accessor :pages
2
+ attr_accessor :pages, :attachments
3
3
  end
@@ -1,6 +1,6 @@
1
1
  module Harmony
2
2
  module Service
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harmony-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sneakers
@@ -118,8 +118,6 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - ".gitignore"
120
120
  - ".rspec"
121
- - ".ruby-gemset"
122
- - ".ruby-version"
123
121
  - ".travis.yml"
124
122
  - Gemfile
125
123
  - LICENSE.txt
@@ -127,6 +125,9 @@ files:
127
125
  - Rakefile
128
126
  - bin/harmony_service
129
127
  - harmony-service.gemspec
128
+ - images/build_settings.png
129
+ - images/calc_page_setup.png
130
+ - images/service_settings.png
130
131
  - lib/harmony/service.rb
131
132
  - lib/harmony/service/action_list/action_request.rb
132
133
  - lib/harmony/service/action_list/item.rb
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  version: '0'
168
169
  requirements: []
169
170
  rubyforge_project:
170
- rubygems_version: 2.4.5.1
171
+ rubygems_version: 2.6.10
171
172
  signing_key:
172
173
  specification_version: 4
173
174
  summary: Gem which helps you to build Harmony services
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- harmony-service
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.2.3