kindara-client 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a3e3445575977c114988fc3d16f0e16e1f2c27de
4
+ data.tar.gz: 85ed22cedcfc664e2c389ff3c46b5e74dd11a649
5
+ SHA512:
6
+ metadata.gz: 8829afaa59bf9928d3b3e248a3f9dd1abc01e898473d074d64e3223eebf92a974c33253213458d350fe1a54866b289faf72da71c4342733b97d67de16026a04d
7
+ data.tar.gz: f60fe5e5274ff770d00e31540b5b6d87487387061c407b6a05783deb6f6110ef7d2a26b28fee8521e1cb19bd7a35e739f0482bd88bac5b7fab0c62d848cff32a
@@ -0,0 +1 @@
1
+ require_relative "kindara"
@@ -0,0 +1,11 @@
1
+ require "http"
2
+ require "json"
3
+
4
+ module Kindara
5
+ require_relative "kindara/version"
6
+ require_relative "kindara/account"
7
+ require_relative "kindara/request"
8
+ require_relative "kindara/client"
9
+ require_relative "kindara/day"
10
+ require_relative "kindara/cycle"
11
+ end
@@ -0,0 +1,36 @@
1
+ module Kindara
2
+ class Account
3
+
4
+ # singleton method goes at the top
5
+ def self.info(client)
6
+ new(Kindara::Request.new("account", "info", client.to_hash).call.fetch("account"))
7
+ end
8
+
9
+ def self.authenticate(email, password)
10
+ Kindara::Client.new(Kindara::Request.new("account", "auth", {"email" => email, "password" => password}))
11
+ end
12
+
13
+ def initialize(payload)
14
+ @username = payload.fetch("username")
15
+ @average_cycle = payload.fetch("average_cycle")
16
+ @average_luteal = payload.fetch("average_luteal")
17
+ @average_period = payload.fetch("average_period")
18
+ end
19
+
20
+ def username
21
+ @username
22
+ end
23
+
24
+ def average_cycle
25
+ @average_cycle
26
+ end
27
+
28
+ def average_luteal
29
+ @average_luteal
30
+ end
31
+
32
+ def average_period
33
+ @average_period
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,27 @@
1
+ module Kindara
2
+ class Client
3
+
4
+ def initialize(request)
5
+ @request = request
6
+ end
7
+
8
+ def to_hash
9
+ {"token" => get_token}
10
+ end
11
+
12
+ def to_hash_with_cycle_days
13
+ {"token" => get_token, "cycle_day" => "yes"}
14
+ end
15
+
16
+ def to_hash_with_chart_data
17
+ {"token" => get_token, "chart" => "yes"}
18
+ end
19
+
20
+ private def get_token
21
+ @request.call.fetch("token")
22
+ end
23
+
24
+ # Ruby 2.1+ Has no arguments, every method becomes private
25
+
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ module Kindara
2
+ class Cycle
3
+
4
+ def self.pull(client)
5
+ Kindara::Request.new("cycle", "pull", client.to_hash_with_chart_data).call.fetch("cycles").map do |cycle|
6
+ new(cycle)
7
+ end
8
+ end
9
+
10
+ def initialize(payload)
11
+ @start = payload.fetch("start")
12
+ @end = payload.fetch("end")
13
+ @updated = payload.fetch("updated")
14
+ @bardo = payload.fetch("bardo")
15
+ @pregnancy = payload.fetch("pregnancy")
16
+ @custom = payload.fetch("custom")
17
+ @temp_shift = payload.fetch("temp_shift")
18
+ @coverline = payload.fetch("coverline")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,61 @@
1
+ module Kindara
2
+ class Day
3
+
4
+ def self.pull(client)
5
+ Kindara::Request.new("day", "pull", client.to_hash_with_cycle_days).call.fetch("days").map do |day|
6
+ new(day)
7
+ end
8
+ end
9
+
10
+ def initialize(payload)
11
+ @date = payload.fetch("date")
12
+ @updated = payload.fetch("updated", nil)
13
+ @cycle_day = payload.fetch("cycle_day", nil)
14
+ @temperature = payload.fetch("temperature", nil)
15
+ @questionable_temp = payload.fetch("questionable_temp", nil)
16
+ @temp_shift = payload.fetch("temp_shift", nil)
17
+ @no_fluid = payload.fetch("no_fluid", nil)
18
+ @fluid_sticky = payload.fetch("fluid_sticky", nil)
19
+ @fluid_creamy = payload.fetch("fluid_creamy", nil)
20
+ @fluid_eggwhite = payload.fetch("fluid_eggwhite", nil)
21
+ @fluid_watery = payload.fetch("fluid_watery", nil)
22
+ @cervix_height = payload.fetch("cervix_height", nil)
23
+ @cervix_openness = payload.fetch("cervix_openness", nil)
24
+ @cervix_firmness = payload.fetch("cervix_firmness", nil)
25
+ @opk = payload.fetch("opk", nil)
26
+ @peak_day = payload.fetch("peak_day", nil)
27
+ @sex = payload.fetch("sex", nil)
28
+ @first_day = payload.fetch("first_day", nil)
29
+ @menstruation = payload.fetch("menstruation", nil)
30
+ @custom = payload.fetch("custom", nil)
31
+ @notes = payload.fetch("notes", nil)
32
+ end
33
+
34
+ def to_hash
35
+ {
36
+ "date" => @date,
37
+ "updated" => @updated,
38
+ "cycle_day" => @cycle_day,
39
+ "temperature" => @temperature,
40
+ "questionable_temp" => @questionable_temp,
41
+ "temp_shift" => @temp_shift,
42
+ "no_fluid" => @no_fluid,
43
+ "fluid_sticky" => @fluid_sticky,
44
+ "fluid_creamy" => @fluid_creamy,
45
+ "fluid_eggwhite" => @fluid_eggwhite,
46
+ "fluid_watery" => @fluid_watery,
47
+ "cervix_height" => @cervix_height,
48
+ "cervix_openness" => @cervix_openness,
49
+ "cervix_firmness" => @cervix_firmness,
50
+ "opk" => @opk,
51
+ "peak_day" => @peak,
52
+ "sex" => @sex,
53
+ "first_day" => @first,
54
+ "menstruation" => @menstruation,
55
+ "custom" => @custom,
56
+ "notes" => @notes
57
+ }
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,36 @@
1
+ module Kindara
2
+ class Request
3
+
4
+ ENDPOINT = "https://kindara-app.appspot.com/api"
5
+
6
+ def initialize(resource, action, payload)
7
+ @resource = resource
8
+ @action = action
9
+ @payload = payload
10
+ end
11
+
12
+ def call
13
+ JSON.parse(HTTP.post(uri, :form => payload).to_s)
14
+ end
15
+
16
+ def uri
17
+ "#{endpoint}/#{resource}.#{action}"
18
+ end
19
+
20
+ def endpoint
21
+ ENDPOINT
22
+ end
23
+
24
+ def resource
25
+ @resource
26
+ end
27
+
28
+ def action
29
+ @action
30
+ end
31
+
32
+ def payload
33
+ @payload
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module Kindara
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ describe Kindara::Account do
4
+ let("payload") do
5
+ { "username" => "Holly",
6
+ "average_cycle" => 32,
7
+ "average_luteal" => 14,
8
+ "average_period" => 3}
9
+ end
10
+
11
+ let("account") do
12
+ described_class.new(payload)
13
+ end
14
+
15
+ let("account_username") do
16
+ "Holly"
17
+ end
18
+
19
+ describe "#username" do
20
+ let("username") do
21
+ account.username
22
+ end
23
+
24
+ it "returns the name" do
25
+ expect(username).to eq(account_username)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ describe Kindara::Request do
4
+ describe ".authenticate" do
5
+ let("authenticate") do
6
+ described_class.authenticate
7
+ end
8
+ end
9
+
10
+ describe "#call" do
11
+ let("call") do
12
+ request.call
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe Kindara::VERSION do
4
+ it "should be a string" do
5
+ expect(Kindara::VERSION).to be_kind_of(String)
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ require "spec_helper"
2
+
3
+ describe Kindara do
4
+
5
+ end
@@ -0,0 +1,6 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
4
+ require "pry"
5
+ require "rspec"
6
+ require "kindara"
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kindara-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Machiko Yasuda
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-doc
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.6'
97
+ description: Making it easier to access personal Kindara data
98
+ email:
99
+ - machikoyasuda@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - lib/kindara-client.rb
105
+ - lib/kindara.rb
106
+ - lib/kindara/account.rb
107
+ - lib/kindara/client.rb
108
+ - lib/kindara/cycle.rb
109
+ - lib/kindara/day.rb
110
+ - lib/kindara/request.rb
111
+ - lib/kindara/version.rb
112
+ - spec/lib/kindara/account_spec.rb
113
+ - spec/lib/kindara/request_spec.rb
114
+ - spec/lib/kindara/version_spec.rb
115
+ - spec/lib/kindara_spec.rb
116
+ - spec/spec_helper.rb
117
+ homepage: http://machikoyasuda.github.io/kindara
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.5.1
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: An API client for the Kindara mobile application
141
+ test_files:
142
+ - spec/lib/kindara/account_spec.rb
143
+ - spec/lib/kindara/request_spec.rb
144
+ - spec/lib/kindara/version_spec.rb
145
+ - spec/lib/kindara_spec.rb
146
+ - spec/spec_helper.rb