familyapp_sdk 0.1.3 → 0.1.6
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 +4 -4
- data/.DS_Store +0 -0
- data/README.md +16 -1
- data/docker-compose.yml +4 -0
- data/lib/familyapp_sdk.rb +3 -0
- data/lib/familyapp_sdk/client.rb +8 -0
- data/lib/familyapp_sdk/components/button.rb +18 -0
- data/lib/familyapp_sdk/components/element.rb +21 -0
- data/lib/familyapp_sdk/components/quick_reply.rb +3 -2
- data/lib/familyapp_sdk/components/template.rb +21 -0
- data/lib/familyapp_sdk/message.rb +1 -1
- data/lib/familyapp_sdk/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 345704b044618930921a64f8c2e49b97573a38cc
|
4
|
+
data.tar.gz: 3609b98bf1940c37f38345427351a77c15eed9b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca63940c4e8e56d8f11e0fba84ffca4934ab77b5281d8006e74f11bdde166a5f12e36087743116bbaf04a9869edb232f54cfebf955228c6974c1797970b1c0ac
|
7
|
+
data.tar.gz: ce9a308696c564e19ddd26e95c79e47b6a61473b44e6f21473e2b55908ed16b5c0cc699af73bacadfd536214e58449c9fe33183c7bacc8a09db8d5e7c6862fba
|
data/.DS_Store
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -20,6 +20,21 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install familyapp_sdk
|
22
22
|
|
23
|
+
## Configuration
|
24
|
+
|
25
|
+
### Initializer
|
26
|
+
|
27
|
+
Create `familyapp_sdk.rb` initializer in you app directory and paste:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# YOUR_APP/config/initializers/familyapp_sdk.rb
|
31
|
+
FamilyappSdk.configure do |config|
|
32
|
+
config.verify_token = '<VERIFY_TOKEN>'
|
33
|
+
config.access_token = '<ACCESS_TOKEN>'
|
34
|
+
config.api_host = '<API_HOST>' # Optional field for staging env
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
23
38
|
## Usage
|
24
39
|
|
25
40
|
TODO: Write usage instructions here
|
@@ -32,7 +47,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
47
|
|
33
48
|
## Contributing
|
34
49
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/familyfabric/familyapp_sdk.rb.
|
36
51
|
|
37
52
|
## License
|
38
53
|
|
data/docker-compose.yml
ADDED
data/lib/familyapp_sdk.rb
CHANGED
@@ -23,4 +23,7 @@ require 'familyapp_sdk/engine'
|
|
23
23
|
require 'familyapp_sdk/client'
|
24
24
|
require 'familyapp_sdk/message'
|
25
25
|
|
26
|
+
require 'familyapp_sdk/components/button'
|
27
|
+
require 'familyapp_sdk/components/element'
|
26
28
|
require 'familyapp_sdk/components/quick_reply'
|
29
|
+
require 'familyapp_sdk/components/template'
|
data/lib/familyapp_sdk/client.rb
CHANGED
@@ -2,6 +2,14 @@ require 'rest-client'
|
|
2
2
|
|
3
3
|
module FamilyappSdk
|
4
4
|
class Client
|
5
|
+
def self.get_family(family_id)
|
6
|
+
url = "/bot_api/v1/families/#{family_id}"
|
7
|
+
RestClient.get(
|
8
|
+
FamilyappSdk.config.api_host + url,
|
9
|
+
{ Authorization: FamilyappSdk.config.access_token }
|
10
|
+
) { |response, request, result| response }
|
11
|
+
end
|
12
|
+
|
5
13
|
def self.update_profile(family_id, family_user_id, data)
|
6
14
|
url = "/bot_api/v1/families/#{family_id}/family_users/#{family_user_id}"
|
7
15
|
RestClient.patch(
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module FamilyappSdk
|
2
|
+
module Components
|
3
|
+
class Button
|
4
|
+
attr_accessor :web_url, :payload, :title, :type
|
5
|
+
|
6
|
+
def initialize(type:, title:, payload: nil, web_url: nil)
|
7
|
+
@button_type = type
|
8
|
+
@title = title
|
9
|
+
@payload = payload
|
10
|
+
@web_url = web_url
|
11
|
+
end
|
12
|
+
|
13
|
+
def build
|
14
|
+
instance_values.delete_if { |_attribute, value| value.nil? }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FamilyappSdk
|
2
|
+
module Components
|
3
|
+
class Element
|
4
|
+
attr_accessor :type, :title, :subtitle, :image, :url, :payload, :buttons
|
5
|
+
|
6
|
+
def initialize(type:, title: nil, subtitle: nil, image: nil, url: nil, payload: nil, buttons: nil)
|
7
|
+
@type = type
|
8
|
+
@title = title
|
9
|
+
@subtitle = subtitle
|
10
|
+
@image = image
|
11
|
+
@url = url
|
12
|
+
@payload = payload
|
13
|
+
@buttons = build_buttons(buttons)
|
14
|
+
end
|
15
|
+
|
16
|
+
def build
|
17
|
+
instance_values.delete_if { |_attribute, value| value.nil? }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -3,10 +3,11 @@ module FamilyappSdk
|
|
3
3
|
class QuickReply
|
4
4
|
attr_accessor :title, :payload, :image
|
5
5
|
|
6
|
-
def initialize(title:, payload: nil, image: nil)
|
6
|
+
def initialize(title:, payload: nil, image: nil, color: nil)
|
7
7
|
@title = title
|
8
8
|
@payload = payload
|
9
9
|
@image = image
|
10
|
+
@color = color
|
10
11
|
end
|
11
12
|
|
12
13
|
def build
|
@@ -14,4 +15,4 @@ module FamilyappSdk
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
17
|
-
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FamilyappSdk
|
2
|
+
module Components
|
3
|
+
class Templates
|
4
|
+
attr_accessor :template_type, :elements_attributes, :buttons_attributes
|
5
|
+
|
6
|
+
def initialize(type:, elements: nil, buttons: nil)
|
7
|
+
@template_type = type
|
8
|
+
@elements_attributes = build_attributes(elements)
|
9
|
+
@buttons_attributes = build_attributes(buttons)
|
10
|
+
end
|
11
|
+
|
12
|
+
def build
|
13
|
+
instance_values.delete_if { |_attribute, value| value.nil? }
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_attributes(attributes)
|
17
|
+
attributes.map(&:build) if attributes.present?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: familyapp_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Familyapp API Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,11 +101,15 @@ files:
|
|
101
101
|
- bin/console
|
102
102
|
- bin/setup
|
103
103
|
- config/routes.rb
|
104
|
+
- docker-compose.yml
|
104
105
|
- familyapp_sdk.gemspec
|
105
106
|
- lib/.DS_Store
|
106
107
|
- lib/familyapp_sdk.rb
|
107
108
|
- lib/familyapp_sdk/client.rb
|
109
|
+
- lib/familyapp_sdk/components/button.rb
|
110
|
+
- lib/familyapp_sdk/components/element.rb
|
108
111
|
- lib/familyapp_sdk/components/quick_reply.rb
|
112
|
+
- lib/familyapp_sdk/components/template.rb
|
109
113
|
- lib/familyapp_sdk/configuration.rb
|
110
114
|
- lib/familyapp_sdk/engine.rb
|
111
115
|
- lib/familyapp_sdk/message.rb
|